complete removal of cases class and related logic
This commit is contained in:
parent
0bec4041ae
commit
1368e33864
3 changed files with 0 additions and 72 deletions
|
|
@ -376,52 +376,6 @@ class ArveData(BaseRequestHandler):
|
|||
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',
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -477,9 +477,6 @@
|
|||
<div class="col-sm-4"><label class="col-form-label pt-0">New confirmed cases (weekly):</label></div>
|
||||
<div class="col-sm-6 pl-0 align-self-center">
|
||||
<input type="number" step="any" id="geographic_cases" class="non_zero form-control" name="geographic_cases" placeholder="Cases (#7-day rolling avg)" min="0">
|
||||
<small id="source_geographic_cases" class="form-text text-muted" style="display: none">
|
||||
Source: World Health Organization.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
|
|
|
|||
Loading…
Reference in a new issue