diff --git a/caimira/apps/calculator/__init__.py b/caimira/apps/calculator/__init__.py index e5f2e976..5a746648 100644 --- a/caimira/apps/calculator/__init__.py +++ b/caimira/apps/calculator/__init__.py @@ -376,52 +376,6 @@ async def get(self, hotel_id, floor_id): return self.finish(response.body) -class CasesData(BaseRequestHandler): - async def get(self, country): - http_client = tornado.httpclient.AsyncHTTPClient() - try: - country_name = await self.get_country_name(country, http_client) - if not country_name: - return self.finish('Country not found') - - cases_data = await self.get_cases_data(country_name, http_client) - if not cases_data: - return self.finish('Data not available') - - return self.finish(str(round(cases_data))) - except Exception as e: - print("Something went wrong: %s" % e) - return self.finish('Internal Server Error', status_code=500) - - async def get_country_name(self, country_code, http_client): - url = f'https://restcountries.com/v3.1/alpha/{country_code}?fields=name' - try: - response = await http_client.fetch(url) - if response.code != 200: - return None - data = json.loads(response.body) - return data['name']['common'] if 'name' in data else None - except Exception as e: - print("Something went wrong: %s" % e) - return None - - async def get_cases_data(self, country_name, http_client): - url = 'https://covid19.who.int/WHO-COVID-19-global-data.csv' - try: - response = await http_client.fetch(url) - if response.code != 200: - return None - data = response.body.decode('utf-8') - df = pd.read_csv(StringIO(data)) - cases = df[df['Country'] == country_name] - if cases.empty: - return None - return cases['New_cases'].mean() - except Exception as e: - print("Something went wrong: %s" % e) - return None - - class GenericExtraPage(BaseRequestHandler): def initialize(self, active_page: str, filename: str): @@ -517,7 +471,6 @@ def make_app( (get_root_calculator_url(r'/report-json'), ConcentrationModelJsonResponse), (get_root_calculator_url(r'/baseline-model/result'), StaticModel), (get_root_calculator_url(r'/api/arve/v1/(.*)/(.*)'), ArveData), - (get_root_calculator_url(r'/cases/(.*)'), CasesData), # Generic Pages (get_root_url(r'/about'), GenericExtraPage, { 'active_page': 'about', diff --git a/caimira/apps/calculator/static/js/form.js b/caimira/apps/calculator/static/js/form.js index 98e7834e..e63bbb45 100644 --- a/caimira/apps/calculator/static/js/form.js +++ b/caimira/apps/calculator/static/js/form.js @@ -293,10 +293,6 @@ function on_exposure_change() { if (this.checked) { getChildElement($(this)).show(); require_fields(this); - if (this.id == "p_probabilistic_exposure") { - // Update geographic_cases - geographic_cases($('[name="location_name"]')[0].value.split(', ')[1]); - }; } else { getChildElement($(this)).hide(); @@ -422,22 +418,6 @@ function show_sensors_data(url) { } }; -function geographic_cases(location_country_name) { - $.ajax({ - url: `${$('#url_prefix').data().calculator_prefix}/cases/${location_country_name}`, - type: 'GET', - success: function (result) { - if (result != 'Country not found') { - $('#geographic_cases').val(result); - result != 'Country not found' ? $('#source_geographic_cases').show() : $('#source_geographic_cases').hide(); - } - }, - error: function(_, _, errorThrown) { - console.log(errorThrown); - } - }); -} - $("#sensors").change(function (el) { sensor_id = DATA_FROM_SENSORS.findIndex(function(sensor) { return sensor.RoomId == el.target.value @@ -999,8 +979,6 @@ $(document).ready(function () { $('[name="location_longitude"]').val('6.14275') } } - // Handle WHO source message if geographic_cases pre-defined value is modified by user - $('#geographic_cases').change(() => $('#source_geographic_cases').hide()); // When the document is ready, deal with the fact that we may be here // as a result of a forward/back browser action. If that is the case, update diff --git a/caimira/apps/templates/base/calculator.form.html.j2 b/caimira/apps/templates/base/calculator.form.html.j2 index aa6271bf..1d444a5d 100644 --- a/caimira/apps/templates/base/calculator.form.html.j2 +++ b/caimira/apps/templates/base/calculator.form.html.j2 @@ -477,9 +477,6 @@
-