feat(crons): fixed health check cron
feat(crons): refactored main
This commit is contained in:
parent
753d1cac11
commit
3dfa487ac5
4 changed files with 12 additions and 6 deletions
|
|
@ -280,7 +280,7 @@ def cron():
|
|||
# this cron is used to correct the sessions&events count every week
|
||||
def weekly_cron():
|
||||
with pg_client.PostgresClient(long_query=True) as cur:
|
||||
query = cur.mogrify("""SELECT project_id
|
||||
query = cur.mogrify("""SELECT project_id,
|
||||
projects_stats.last_update_at
|
||||
FROM public.projects
|
||||
LEFT JOIN public.projects_stats USING (project_id)
|
||||
|
|
@ -298,7 +298,7 @@ def weekly_cron():
|
|||
"events_count": 0}
|
||||
|
||||
query = cur.mogrify("""SELECT COUNT(1) AS sessions_count,
|
||||
SUM(events_count) AS events_count
|
||||
COALESCE(SUM(events_count),0) AS events_count
|
||||
FROM public.sessions
|
||||
WHERE project_id=%(project_id)s
|
||||
AND start_ts<=%(end_ts)s
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ def default_action(action):
|
|||
async def _func():
|
||||
print(f"{action} not found in crons-definitions")
|
||||
print("possible actions:")
|
||||
print(ACTIONS.keys())
|
||||
print(list(ACTIONS.keys()))
|
||||
|
||||
return _func
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ async def process(action):
|
|||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2 or len(sys.argv[1]) < 1:
|
||||
print("please provide actions as argument\npossible actions:")
|
||||
print(ACTIONS.keys())
|
||||
print(list(ACTIONS.keys()))
|
||||
else:
|
||||
print(f"action: {sys.argv[1]}")
|
||||
asyncio.run(process(sys.argv[1]))
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ def cron():
|
|||
# this cron is used to correct the sessions&events count every week
|
||||
def weekly_cron():
|
||||
with pg_client.PostgresClient(long_query=True) as cur:
|
||||
query = cur.mogrify("""SELECT project_id
|
||||
query = cur.mogrify("""SELECT project_id,
|
||||
projects_stats.last_update_at
|
||||
FROM public.projects
|
||||
LEFT JOIN public.projects_stats USING (project_id)
|
||||
|
|
@ -307,7 +307,7 @@ def weekly_cron():
|
|||
"events_count": 0}
|
||||
|
||||
query = cur.mogrify("""SELECT COUNT(1) AS sessions_count,
|
||||
SUM(events_count) AS events_count
|
||||
COALESCE(SUM(events_count),0) AS events_count
|
||||
FROM public.sessions
|
||||
WHERE project_id=%(project_id)s
|
||||
AND start_ts<=%(end_ts)s
|
||||
|
|
|
|||
6
ee/api/run-crons-dev.sh
Executable file
6
ee/api/run-crons-dev.sh
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/zsh
|
||||
APP_NAME=crons \
|
||||
PG_MINCONN=2 \
|
||||
PG_MAXCONN=10 \
|
||||
PG_POOL=false \
|
||||
python app_crons.py $@
|
||||
Loading…
Add table
Reference in a new issue