forked from MarseyWorld/MarseyWorld
sfd
parent
09e15a1961
commit
f306d76373
|
@ -83,32 +83,7 @@ def stats():
|
|||
|
||||
active_users = set(posters) | set(commenters) | set(voters) | set(commentvoters)
|
||||
|
||||
furries = g.db.query(User.id).filter(User.house.like('Furry%')).count()
|
||||
femboys = g.db.query(User.id).filter(User.house.like('Femboy%')).count()
|
||||
vampires = g.db.query(User.id).filter(User.house.like('Vampire%')).count()
|
||||
racists = g.db.query(User.id).filter(User.house.like('Racist%')).count()
|
||||
|
||||
furries2 = g.db.query(User.id).filter(User.house == 'Furry Founder').count()
|
||||
femboys2 = g.db.query(User.id).filter(User.house == 'Femboy Founder').count()
|
||||
vampires2 = g.db.query(User.id).filter(User.house == 'Vampire Founder').count()
|
||||
racists2 = g.db.query(User.id).filter(User.house == 'Racist Founder').count()
|
||||
|
||||
furries3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Furry%')).scalar()
|
||||
femboys3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Femboy%')).scalar()
|
||||
vampires3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Vampire%')).scalar()
|
||||
racists3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Racist%')).scalar()
|
||||
|
||||
furries4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Furry%')).scalar()
|
||||
femboys4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Femboy%')).scalar()
|
||||
vampires4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Vampire%')).scalar()
|
||||
racists4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Racist%')).scalar()
|
||||
|
||||
furries5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Furry%')).scalar()
|
||||
femboys5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Femboy%')).scalar()
|
||||
vampires5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Vampire%')).scalar()
|
||||
racists5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Racist%')).scalar()
|
||||
|
||||
return {"marseys": g.db.query(Marsey.name).count(),
|
||||
stats = {"marseys": g.db.query(Marsey.name).count(),
|
||||
"users": g.db.query(User.id).count(),
|
||||
"private users": g.db.query(User.id).filter_by(is_private=True).count(),
|
||||
"banned users": g.db.query(User.id).filter(User.is_banned > 0).count(),
|
||||
|
@ -136,7 +111,36 @@ def stats():
|
|||
"total awards": g.db.query(AwardRelationship.id).count(),
|
||||
"awards given": g.db.query(AwardRelationship.id).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count(),
|
||||
"users who posted, commented, or voted in the past 7 days": len(active_users),
|
||||
"House furry members": furries,
|
||||
}
|
||||
|
||||
|
||||
if SITE_NAME == 'rDrama':
|
||||
furries = g.db.query(User.id).filter(User.house.like('Furry%')).count()
|
||||
femboys = g.db.query(User.id).filter(User.house.like('Femboy%')).count()
|
||||
vampires = g.db.query(User.id).filter(User.house.like('Vampire%')).count()
|
||||
racists = g.db.query(User.id).filter(User.house.like('Racist%')).count()
|
||||
|
||||
furries2 = g.db.query(User.id).filter(User.house == 'Furry Founder').count()
|
||||
femboys2 = g.db.query(User.id).filter(User.house == 'Femboy Founder').count()
|
||||
vampires2 = g.db.query(User.id).filter(User.house == 'Vampire Founder').count()
|
||||
racists2 = g.db.query(User.id).filter(User.house == 'Racist Founder').count()
|
||||
|
||||
furries3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Furry%')).scalar()
|
||||
femboys3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Femboy%')).scalar()
|
||||
vampires3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Vampire%')).scalar()
|
||||
racists3 = g.db.query(func.sum(User.truecoins)).filter(User.house.like('Racist%')).scalar()
|
||||
|
||||
furries4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Furry%')).scalar()
|
||||
femboys4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Femboy%')).scalar()
|
||||
vampires4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Vampire%')).scalar()
|
||||
racists4 = g.db.query(func.sum(User.post_count)).filter(User.house.like('Racist%')).scalar()
|
||||
|
||||
furries5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Furry%')).scalar()
|
||||
femboys5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Femboy%')).scalar()
|
||||
vampires5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Vampire%')).scalar()
|
||||
racists5 = g.db.query(func.sum(User.comment_count)).filter(User.house.like('Racist%')).scalar()
|
||||
|
||||
stats2 = {"House furry members": furries,
|
||||
"House femboy members": femboys,
|
||||
"House vampire members": vampires,
|
||||
"House racist members": racists,
|
||||
|
@ -159,8 +163,11 @@ def stats():
|
|||
"House furry total comments": furries5,
|
||||
"House femboy total comments": femboys5,
|
||||
"House vampire total comments": vampires5,
|
||||
"House racist total comments": racists5,
|
||||
}
|
||||
"House racist total comments": racists5}
|
||||
|
||||
stats = stats | stats2
|
||||
|
||||
return stats
|
||||
|
||||
@app.get("/chart")
|
||||
def chart():
|
||||
|
@ -197,12 +204,8 @@ def cached_chart(kind):
|
|||
)
|
||||
today_cutoff = calendar.timegm(midnight_this_morning)
|
||||
|
||||
if kind == "daily":
|
||||
file = f"/{SITE}_daily.png"
|
||||
day_cutoffs = [today_cutoff - 86400 * i for i in range(47)][1:]
|
||||
else:
|
||||
file = f"/{SITE}_weekly.png"
|
||||
day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(47)][1:]
|
||||
if kind == "daily": day_cutoffs = [today_cutoff - 86400 * i for i in range(47)][1:]
|
||||
else: day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(47)][1:]
|
||||
|
||||
day_cutoffs.insert(0, calendar.timegm(now))
|
||||
|
||||
|
@ -248,6 +251,8 @@ def cached_chart(kind):
|
|||
posts_chart.legend(loc='upper left', frameon=True)
|
||||
comments_chart.legend(loc='upper left', frameon=True)
|
||||
|
||||
file = f"/{SITE}_{kind}.png"
|
||||
|
||||
plt.savefig(file)
|
||||
plt.clf()
|
||||
return file
|
||||
|
|
Loading…
Reference in New Issue