-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
karelia parse_full_list get_division_problems fix PgStatTuple atcoder account renaming fast check linked accounts
- Loading branch information
Showing
39 changed files
with
545 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
from django.apps import AppConfig | ||
|
||
from pyclist.decorators import run_once, run_only_in_production | ||
|
||
|
||
class LogifyConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'logify' | ||
|
||
@run_only_in_production | ||
@run_once('logify_ready') | ||
def ready(self): | ||
from logify.models import EventLog, EventStatus | ||
EventLog.objects.filter(status=EventStatus.IN_PROGRESS).update(status=EventStatus.INTERRUPTED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import re | ||
from logging import getLogger | ||
|
||
import tqdm | ||
from django.core.management.base import BaseCommand | ||
from django.db import connection | ||
|
||
from logify.models import PgStatTuple | ||
from utils.attrdict import AttrDict | ||
from utils.db import dictfetchone, find_app_by_table | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Updates the PgStatTuple table with fresh data from pgstattuple' | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.logger = getLogger('logify.update_pgstattuple') | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('-n', '--limit', type=int, help='number of tables') | ||
parser.add_argument('-f', '--search', type=str, help='search tables') | ||
|
||
def handle(self, *args, **options): | ||
self.stdout.write(str(options)) | ||
args = AttrDict(options) | ||
|
||
with connection.cursor() as cursor: | ||
cursor.execute("SELECT tablename FROM pg_tables WHERE schemaname='public'") | ||
tables = [row[0] for row in cursor.fetchall()] | ||
if args.limit: | ||
tables = tables[:args.limit] | ||
if args.search: | ||
tables = [table for table in tables if re.search(args.search, table)] | ||
|
||
for table in tqdm.tqdm(tables, desc='tables'): | ||
cursor.execute(f"SELECT * FROM pgstattuple('{table}')") | ||
stats = dictfetchone(cursor) | ||
defaults = {'app_name': find_app_by_table(table), **stats} | ||
PgStatTuple.objects.update_or_create(table_name=table, defaults=defaults) |
Oops, something went wrong.