mirror of
https://git.ugnet.gay/CrossTalk/azul.git
synced 2026-05-27 22:59:49 +00:00
init
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from datetime import datetime, timedelta
|
||||
from core import db
|
||||
from core.conn import Conn
|
||||
import settings
|
||||
|
||||
# TODO: INS-ize this
|
||||
def main(*, since: int = 60, verbose: bool = False) -> None:
|
||||
online_since = datetime.utcnow() - timedelta(minutes = since)
|
||||
total = 0
|
||||
total_online = 0
|
||||
|
||||
conn = Conn(settings.DB)
|
||||
with conn.session() as sess:
|
||||
for u in sess.query(db.User).all():
|
||||
total += 1
|
||||
if verbose:
|
||||
print(u.email)
|
||||
if online_since is not None and u.date_login is not None:
|
||||
total_online += (1 if u.date_login >= online_since else 0)
|
||||
|
||||
print("Total:", total)
|
||||
if online_since is not None:
|
||||
print("Online:", total_online)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import funcli
|
||||
funcli.main()
|
||||
Reference in New Issue
Block a user