-
-
Notifications
You must be signed in to change notification settings - Fork 0
add script to populate cms database #153
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
base: cms-upgrade
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## cms-upgrade #153 +/- ##
============================================
Coverage 80.31% 80.31%
============================================
Files 43 43
Lines 1702 1702
Branches 149 149
============================================
Hits 1367 1367
Misses 291 291
Partials 44 44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
benoit74
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not test this but we can anyway fix this after merge should we detect a bug.
Question: will this script be packaged inside the Docker image? It should, in a specific folder just like on Zimfarm (for convenience to access them easily from the container). And any reason to not have a maint-scripts folder in repo just like on Zimfarm?
backend/populate_cms_database.py
Outdated
| """Get existing title by name or create a new one.""" | ||
| title = get_title_by_name_or_none(session, name=name) | ||
|
|
||
| if title: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not write it the other way around:
if not title:
# Create new title
title = Title(name=name)
title.events.append(f"{getnow()}: maintenance script: title created")
session.add(title)
# Shared logic to add a new collectionTitle to the title
If feel like we've duplicated lot of code here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Rationale
This PR adds a script that scans through warehouses, finds zim files and tries to populate CMS database with books/titles based on zim_info retreived from file
Changes
utils/zim.pyfor keeping zim-related functions (copied from zimfarm/worker)This closes #144