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.
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.
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.
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