Improvements
This commit is contained in:
parent
2027d8d1db
commit
a077001503
10
bot.py
10
bot.py
|
@ -10,7 +10,7 @@ from telegram.ext import CommandHandler
|
||||||
from pymongo import MongoClient
|
from pymongo import MongoClient
|
||||||
|
|
||||||
import io
|
import io
|
||||||
from datetime import timedelta as td
|
from datetime import datetime as dt, timedelta as td
|
||||||
|
|
||||||
import matplotlib.dates as mdates
|
import matplotlib.dates as mdates
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
@ -76,11 +76,13 @@ def download():
|
||||||
)
|
)
|
||||||
df = df.loc[df["area"] == "ITA"]
|
df = df.loc[df["area"] == "ITA"]
|
||||||
df["totale"] = pd.to_numeric(df["totale"])
|
df["totale"] = pd.to_numeric(df["totale"])
|
||||||
# df = df[:-1] # Ignore the last day because it's often incomplete
|
if dt.now() - df.index[-1] < td(days=1):
|
||||||
|
df = df[:-1] # Ignore the current day because it's often incomplete
|
||||||
|
|
||||||
|
totalVaccines = sum(df["totale"])
|
||||||
lastWeekData = df.loc[df.index > df.index[-1] - td(days=7)]
|
lastWeekData = df.loc[df.index > df.index[-1] - td(days=7)]
|
||||||
vaccinesPerDayAverage = sum(lastWeekData["totale"]) / 7
|
vaccinesPerDayAverage = sum(lastWeekData["totale"]) / 7
|
||||||
remainingDays = HIT / vaccinesPerDayAverage
|
remainingDays = (HIT - totalVaccines) / vaccinesPerDayAverage
|
||||||
hitDate = df.index[-1] + td(days=remainingDays)
|
hitDate = df.index[-1] + td(days=remainingDays)
|
||||||
|
|
||||||
# Generate plot
|
# Generate plot
|
||||||
|
@ -108,7 +110,7 @@ def download():
|
||||||
with open('out/' + webpage_filename, 'w+') as wf:
|
with open('out/' + webpage_filename, 'w+') as wf:
|
||||||
for line in f.read().splitlines():
|
for line in f.read().splitlines():
|
||||||
if "<!-- totalVaccinations -->" in line:
|
if "<!-- totalVaccinations -->" in line:
|
||||||
line = f"{sum(df['totale'])}"
|
line = f"{totalVaccines}"
|
||||||
elif "<!-- totalVaccinationsLastWeek -->" in line:
|
elif "<!-- totalVaccinationsLastWeek -->" in line:
|
||||||
line = f"{int(vaccinesPerDayAverage*7)}"
|
line = f"{int(vaccinesPerDayAverage*7)}"
|
||||||
elif "<!-- vaccinesPerDay -->" in line:
|
elif "<!-- vaccinesPerDay -->" in line:
|
||||||
|
|
Loading…
Reference in New Issue