Skip to content

Commit

Permalink
open access: addition of logging for queries (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
drjova authored Nov 5, 2024
1 parent 8529734 commit 01bb4bb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dags/open_access/open_access.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import open_access.constants as constants
import pendulum
import logging
from airflow.decorators import dag, task
from common.models.open_access.open_access import OAOpenAccess
from common.operators.sqlalchemy_operator import sqlalchemy_task
Expand All @@ -13,6 +14,7 @@
)
from sqlalchemy.sql import func

logger = logging.getLogger(__name__)

@dag(
start_date=pendulum.today("UTC").add(days=-1),
Expand All @@ -24,18 +26,21 @@ def oa_dag():
def fetch_closed_access_count(query_object, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_comments(parameters=parameters)

@task(executor_config=kubernetes_executor_config)
def fetch_bronze_open_access_count(query_object, closed_access, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_comments(parameters=parameters, previous=closed_access)

@task(executor_config=kubernetes_executor_config)
def fetch_gold_open_access_count(query_object, bronze_access, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_parsed_records(
parameters=parameters,
count_function=get_golden_access_count,
Expand All @@ -46,6 +51,7 @@ def fetch_gold_open_access_count(query_object, bronze_access, **kwargs):
def fetch_green_open_access_count(query_object, gold_access, **kwargs):
year = kwargs["params"].get("year")
parameters = generate_params(query_object, year)
logger.info(f"Query: {parameters}")
return fetch_count_from_parsed_records(
parameters=parameters,
count_function=get_green_access_count,
Expand Down

0 comments on commit 01bb4bb

Please sign in to comment.