Skip to content

Commit

Permalink
Merge pull request #51 from codeforIATI/add-logs
Browse files Browse the repository at this point in the history
Add activity count logs
  • Loading branch information
tillywoodfield authored Aug 7, 2024
2 parents c904822 + 40e953a commit d431d47
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion iatidata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,21 @@ def load(processes: int, sample: Optional[int] = None) -> None:
executor.submit(load_dataset, dataset) for dataset in datasets_sample
]
concurrent.futures.wait(futures)
logger.info("Finished loading datasets into database")

engine = get_engine()
with engine.begin() as connection:
activity_result = connection.execute(
text("SELECT COUNT(*) AS count FROM _raw_activity")
).first()
logger.info(
f"Loaded {activity_result.count if activity_result else 0} activities into database"
)
organisation_result = connection.execute(
text("SELECT COUNT(*) AS count FROM _raw_organisation")
).first()
logger.info(
f"Loaded {organisation_result.count if organisation_result else 0} organisations into database"
)


def process_registry() -> None:
Expand Down Expand Up @@ -819,6 +833,16 @@ def postgres_tables(drop_release_objects=False):
with get_engine().begin() as connection:
connection.execute("DROP TABLE IF EXISTS _release_objects")

engine = get_engine()
with engine.begin() as connection:
tables = connection.execute(
text(
"SELECT table_name, rows FROM _tables ORDER BY table_order, table_name"
)
)
for table_name, rows in tables:
logger.info(f"There are {rows} rows in {table_name}")


def augment_transaction():
logger.debug("Augmenting transaction table")
Expand Down

0 comments on commit d431d47

Please sign in to comment.