Added a 0-value verification for geographical cases
This commit is contained in:
parent
5915a0d520
commit
2d909bc905
3 changed files with 5 additions and 2 deletions
|
|
@ -334,6 +334,8 @@ class CasesData(BaseRequestHandler):
|
|||
current_date = str(datetime.datetime.now()).split(' ')[0]
|
||||
eight_days_ago = str(datetime.datetime.now() - datetime.timedelta(days=7)).split(' ')[0]
|
||||
cases = cases.set_index(['Date_reported'])
|
||||
# If any of the 'New_cases' is 0, it means the data is not updated.
|
||||
if (cases.loc[eight_days_ago:current_date]['New_cases'] == 0).any(): return self.finish('')
|
||||
return self.finish(str(round(cases.loc[eight_days_ago:current_date]['New_cases'].mean())))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -424,6 +424,7 @@ function geographic_cases(location_country_name) {
|
|||
type: 'GET',
|
||||
success: function (result) {
|
||||
$('#geographic_cases').val(result);
|
||||
result != '' ? $('#source_geographic_cases').show() : $('#source_geographic_cases').hide();
|
||||
},
|
||||
error: function(_, _, errorThrown) {
|
||||
console.log(errorThrown);
|
||||
|
|
|
|||
|
|
@ -387,9 +387,9 @@
|
|||
</div>
|
||||
<div class="form-group row">
|
||||
<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 pt-1 align-self-center">
|
||||
<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 class="form-text text-muted">
|
||||
<small id="source_geographic_cases" class="form-text text-muted" style="display: none">
|
||||
Source: World Health Organization.
|
||||
</small>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue