for rdrama.net, made it so the weekly chart always start before the site got made, and added variable chart width to accomodate that

remotes/1693045480750635534/spooky-22
Aevann1 2022-05-30 05:16:48 +02:00
parent e52a2e285b
commit 27d81f6506
1 changed files with 14 additions and 6 deletions

View File

@ -232,8 +232,16 @@ def cached_chart(kind, site):
)
today_cutoff = calendar.timegm(midnight_this_morning)
if kind == "daily": day_cutoffs = [today_cutoff - 86400 * i for i in range(55)][1:]
else: day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(55)][1:]
if SITE == 'rdrama.net':
time_diff = time.time() - 1619827200
num_of_weeks = int(time_diff / 604800)
chart_width = int(num_of_weeks/1.4)
else:
num_of_weeks = 30
chart_width = 30
if kind == "daily": day_cutoffs = [today_cutoff - 86400 * i for i in range(num_of_weeks)][1:]
else: day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(num_of_weeks)][1:]
day_cutoffs.insert(0, calendar.timegm(now))
@ -245,11 +253,11 @@ def cached_chart(kind, site):
comment_stats = [g.db.query(Comment).filter(Comment.created_utc < day_cutoffs[i], Comment.created_utc > day_cutoffs[i + 1],Comment.is_banned == False, Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count() for i in range(len(day_cutoffs) - 1)][::-1]
plt.rcParams["figure.figsize"] = (30, 20)
plt.rcParams["figure.figsize"] = (chart_width, 20)
signup_chart = plt.subplot2grid((30, 20), (0, 0), rowspan=6, colspan=30)
posts_chart = plt.subplot2grid((30, 20), (10, 0), rowspan=6, colspan=30)
comments_chart = plt.subplot2grid((30, 20), (20, 0), rowspan=6, colspan=30)
signup_chart = plt.subplot2grid((chart_width, 20), (0, 0), rowspan=6, colspan=chart_width)
posts_chart = plt.subplot2grid((chart_width, 20), (10, 0), rowspan=6, colspan=chart_width)
comments_chart = plt.subplot2grid((chart_width, 20), (20, 0), rowspan=6, colspan=chart_width)
signup_chart.grid(), posts_chart.grid(), comments_chart.grid()