Skip to content

add script to populate cms database#153

Open
elfkuzco wants to merge 4 commits intocms-upgradefrom
populate-cms-database
Open

add script to populate cms database#153
elfkuzco wants to merge 4 commits intocms-upgradefrom
populate-cms-database

Conversation

@elfkuzco
Copy link

@elfkuzco elfkuzco commented Feb 12, 2026

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

  • create utils/zim.py for keeping zim-related functions (copied from zimfarm/worker)
  • add script to populate cms database from zim files in local warehouses

This closes #144

@elfkuzco elfkuzco linked an issue Feb 12, 2026 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.31%. Comparing base (65335f9) to head (f317e13).
⚠️ Report is 3 commits behind head on cms-upgrade.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@elfkuzco elfkuzco requested a review from benoit74 February 12, 2026 08:34
Copy link
Contributor

@benoit74 benoit74 left a 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?

"""Get existing title by name or create a new one."""
title = get_title_by_name_or_none(session, name=name)

if title:
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@elfkuzco elfkuzco requested a review from benoit74 February 12, 2026 15:26
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.

Populate CMS database with existing collections

2 participants