Skip to content

Migrate exists_by_qids_query from all_articles to category_members - #43

Merged
MrIbrahem merged 1 commit into
mainfrom
migrate/all-articles-to-category-members
May 22, 2026
Merged

MrIbrahem merged 1 commit into
mainfrom
migrate/all-articles-to-category-members

Conversation

@MrIbrahem

Copy link
Copy Markdown
Member

This pull request was created by @kiro-agent on behalf of @MrIbrahem 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


Phase 2 of the all_articlescategory_members migration

Implements the rewrite recommended for exists_by_qids_query in docs/all_articles_migration_audit.md (PR #42), bringing the last all_articles reader in this repo in line with the convention already used by the four neighbouring functions in the same file.

Change

src/api_cod/subs/missing_exists.phpexists_by_qids_query:

  • LEFT JOIN all_articles aa ON aa.article_id = q.titleLEFT JOIN category_members cm ON cm.article_id = q.title
  • aa.categorycm.category in the SELECT list, in the optional category = ? filter, and in the optional category IN (... WHERE campaign = ?) filter
  • Doc-comment column hint updated to cm.category

Behaviour

  • With category= or campaign= filter: identical result set. The WHERE clause continues to act as an effective inner-join, returning one row per (qid, code) for articles in the matching category.
  • Without a category/campaign filter: an article that is a member of N categories will now appear N times instead of once. This matches the cardinality the four neighbouring functions in this file already produce against category_members. If the consumer turns out to need the original "1 row per article" shape, we can wrap the join in a GROUP BY article_id subquery in a follow-up — keeping this PR a pure column/table substitution.

Verification

Ran locally inside the sandbox:

$ vendor/bin/phpstan analyse
 [OK] No errors

$ vendor/bin/phpunit tests --testdox
Tests: 97, Assertions: 147 — OK

(The 206 PHPUnit doc-comment-metadata deprecation notices are pre-existing and unrelated to this change.)

After this PR no live code under src/ references all_articles. The schema in sql.sql is intentionally left in place; dropping it is Phase 4 and only happens after the Translation-Dashboard and mdwiki-python-files PRs are merged and observed.

Companion PRs

  • Mdwiki-TD/Translation-Dashboard — same rewrite for the verbatim copy of exists_by_qids_query in new_sql_tables.php
  • Mdwiki-TD/mdwiki-python-files — Phase 1 (the three mdcount/*.py SELECTs and the redundant to_sql write) and Phase 3 (re-pointing fix_it_db.py at the words table)

Replace the LEFT JOIN against all_articles with a LEFT JOIN against
category_members in exists_by_qids_query, matching the convention
already used by the other functions in this file
(exists_statics_by_category, missing_by_lang_and_category,
exists_by_lang_and_category, statics_by_category).

The optional category and campaign filters now read from cm.category
instead of aa.category. Behaviour with a filter applied is unchanged.
Without a filter, articles that belong to multiple categories may now
appear once per category in the result set; this matches the cardinality
the neighbouring queries already produce.

Refs the migration plan in docs/all_articles_migration_audit.md (Phase 2).
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@MrIbrahem has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 3 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1cc5d6fb-647e-41d2-8682-8f9cde61465d

📥 Commits

Reviewing files that changed from the base of the PR and between 0b9e665 and c5db170.

📒 Files selected for processing (1)
  • src/api_cod/subs/missing_exists.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch migrate/all-articles-to-category-members

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the exists_by_qids_query function in src/api_cod/subs/missing_exists.php to use the category_members table instead of all_articles. Feedback highlights that this change may introduce row duplication in the API response, as articles can belong to multiple categories in the new table. To maintain consistency with the previous implementation, it is suggested to use a GROUP BY clause or a subquery to ensure only one row is returned per article when no specific category filter is applied.

Comment thread src/api_cod/subs/missing_exists.php
@MrIbrahem
MrIbrahem merged commit a7012dc into main May 22, 2026
3 checks passed
@MrIbrahem
MrIbrahem deleted the migrate/all-articles-to-category-members branch May 22, 2026 06:47
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