Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library KPIs: items in the institutional repo #31

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Conversation

ErnestaP
Copy link
Contributor

@ErnestaP ErnestaP commented Jul 5, 2024

No description provided.

@ErnestaP ErnestaP force-pushed the library-inspire-kpi branch from 4d8c5ec to 9a0f74c Compare July 8, 2024 09:29
@ErnestaP ErnestaP changed the title WIP: Library KPIs: items in the institutional repo Library KPIs: items in the institutional repo Jul 8, 2024
@ErnestaP ErnestaP self-assigned this Jul 9, 2024
@ErnestaP ErnestaP requested a review from pamfilos July 9, 2024 11:02
Copy link
Contributor

@drjova drjova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, just few comments


results = join_and_add_year(counts)

populate_items_in_the_institutional_repository = PostgresOperator(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the approach of Postgres Operator although I feel reluctant about raw SQL operations. With a quick search I found that it's possible to use SQLAlchemy for this kind of operations https://sorokin.engineer/posts/en/apache_airflow_sqlalchemy_operator.html. Can we give it a try?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ErnestaP only this is missing to investigate, thank you

@ErnestaP ErnestaP force-pushed the library-inspire-kpi branch 2 times, most recently from a7260ec to eaf68ac Compare July 31, 2024 08:22
@sqlalchemy_task(conn_id="superset_qa")
def populate_golden_open_access(results, session, **kwargs):
record = (
session.query(OAGoldenOpenAccess).filter_by(year=results["year"]).first()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will fail if there is None, we have to do first_or_none()

)
@sqlalchemy_task(conn_id="superset_qa")
def populate_open_access(results, session, **kwargs):
record = session.query(OAOpenAccess).filter_by(year=results["year"]).first()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

@drjova drjova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, it looks much cleaner this way! Few minor comments



class LibraryNewItemsInTheInstitutionalRepository(Base):
__tablename__ = "items_in_the_institutional_repository"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
__tablename__ = "items_in_the_institutional_repository"
__tablename__ = "library_items_in_the_institutional_repository"

record = (
session.query(LibraryCernPublicationRecords)
.filter_by(year=results["year"])
.first()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@ErnestaP ErnestaP force-pushed the library-inspire-kpi branch from eaf68ac to 233cc14 Compare July 31, 2024 09:11
@ErnestaP ErnestaP merged commit 305b317 into main Jul 31, 2024
1 check passed
@ErnestaP ErnestaP deleted the library-inspire-kpi branch August 1, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants