hockey-blast-common-lib 0.1.45__tar.gz → 0.1.46__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/PKG-INFO +1 -1
  2. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/aggregate_human_stats.py +11 -11
  3. hockey_blast_common_lib-0.1.46/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
  4. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/restore_sample_db.sh +12 -5
  5. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib.egg-info/PKG-INFO +1 -1
  6. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/setup.py +1 -1
  7. hockey_blast_common_lib-0.1.45/hockey_blast_common_lib/hockey_blast_sample_backup.sql.gz +0 -0
  8. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/MANIFEST.in +0 -0
  9. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/README.md +0 -0
  10. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/__init__.py +0 -0
  11. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/aggregate_all_stats.py +0 -0
  12. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/aggregate_goalie_stats.py +0 -0
  13. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/aggregate_referee_stats.py +0 -0
  14. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/aggregate_skater_stats.py +0 -0
  15. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/assign_skater_skill.py +0 -0
  16. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/db_connection.py +0 -0
  17. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/dump_sample_db.sh +0 -0
  18. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/models.py +0 -0
  19. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/options.py +0 -0
  20. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/skills_in_divisions.py +0 -0
  21. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/skills_propagation.py +0 -0
  22. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/stats_models.py +0 -0
  23. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/stats_utils.py +0 -0
  24. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/utils.py +0 -0
  25. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib/wsgi.py +0 -0
  26. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib.egg-info/SOURCES.txt +0 -0
  27. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib.egg-info/dependency_links.txt +0 -0
  28. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib.egg-info/requires.txt +0 -0
  29. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/hockey_blast_common_lib.egg-info/top_level.txt +0 -0
  30. {hockey_blast_common_lib-0.1.45 → hockey_blast_common_lib-0.1.46}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.45
3
+ Version: 0.1.46
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -440,17 +440,17 @@ def run_aggregate_human_stats():
440
440
  aggregate_human_stats(session, aggregation_type='org', aggregation_id=org_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug, aggregation_window='Daily')
441
441
 
442
442
  # Aggregate by level
443
- # level_ids = session.query(Division.level_id).distinct().all()
444
- # level_ids = [level_id[0] for level_id in level_ids]
445
- # total_levels = len(level_ids)
446
- # processed_levels = 0
447
- # for level_id in level_ids:
448
- # if level_id is None:
449
- # continue
450
- # if human_id_to_debug is None:
451
- # print(f"\rProcessed {processed_levels}/{total_levels} levels ({(processed_levels/total_levels)*100:.2f}%)", end="")
452
- # processed_levels += 1
453
- # aggregate_human_stats(session, aggregation_type='level', aggregation_id=level_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
443
+ level_ids = session.query(Division.level_id).distinct().all()
444
+ level_ids = [level_id[0] for level_id in level_ids]
445
+ total_levels = len(level_ids)
446
+ processed_levels = 0
447
+ for level_id in level_ids:
448
+ if level_id is None:
449
+ continue
450
+ if human_id_to_debug is None:
451
+ print(f"\rProcessed {processed_levels}/{total_levels} levels ({(processed_levels/total_levels)*100:.2f}%)", end="")
452
+ processed_levels += 1
453
+ aggregate_human_stats(session, aggregation_type='level', aggregation_id=level_id, names_to_filter_out=not_human_names, human_id_filter=human_id_to_debug)
454
454
 
455
455
  if __name__ == "__main__":
456
456
  run_aggregate_human_stats()
@@ -9,15 +9,22 @@ DB_PORT=${DB_PORT:-"5432"}
9
9
  COMPRESSED_DUMP_FILE="hockey_blast_sample_backup.sql.gz"
10
10
 
11
11
  # Superuser credentials
12
- SUPERUSER="boss"
13
- SUPERUSER_PASSWORD=${DB_PASSWORD_BOSS:-"your_superuser_password"}
12
+ SUPERUSER="your_superuser"
13
+ SUPERUSER_PASSWORD="your_superuser_password"
14
14
 
15
15
  # Export PGPASSWORD to avoid password prompt
16
16
  export PGPASSWORD=$SUPERUSER_PASSWORD
17
17
 
18
- # Drop the existing database if it exists
19
- psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DB_NAME' AND pid <> pg_backend_pid();"
20
- psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="DROP DATABASE IF EXISTS $DB_NAME"
18
+ # Generate a unique timestamp
19
+ TIMESTAMP=$(date +%Y%m%d%H%M%S)
20
+ BACKUP_DB_NAME="${DB_NAME}_backup_${TIMESTAMP}"
21
+
22
+ # Check if the database exists and rename it if it does
23
+ DB_EXISTS=$(psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --tuples-only --command="SELECT 1 FROM pg_database WHERE datname = '$DB_NAME'")
24
+ if [ "$DB_EXISTS" = "1" ]; then
25
+ psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DB_NAME' AND pid <> pg_backend_pid();"
26
+ psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="ALTER DATABASE $DB_NAME RENAME TO $BACKUP_DB_NAME"
27
+ fi
21
28
 
22
29
  # Create a new database
23
30
  psql --username=$SUPERUSER --host=$DB_HOST --port=$DB_PORT -d postgres --command="CREATE DATABASE $DB_NAME OWNER $SUPERUSER"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hockey-blast-common-lib
3
- Version: 0.1.45
3
+ Version: 0.1.46
4
4
  Summary: Common library for shared functionality and DB models
5
5
  Author: Pavel Kletskov
6
6
  Author-email: kletskov@gmail.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='hockey-blast-common-lib', # The name of your package
5
- version='0.1.45',
5
+ version='0.1.46',
6
6
  description='Common library for shared functionality and DB models',
7
7
  author='Pavel Kletskov',
8
8
  author_email='kletskov@gmail.com',