Skip to content

Fix CSV export truncation + frontend JS null guards#29

Merged
r00bbert merged 2 commits into
mainfrom
fix/export-truncation-and-js-guards
May 21, 2026
Merged

Fix CSV export truncation + frontend JS null guards#29
r00bbert merged 2 commits into
mainfrom
fix/export-truncation-and-js-guards

Conversation

@r00bbert
Copy link
Copy Markdown
Collaborator

@r00bbert r00bbert commented May 21, 2026

Follow-up to #28. Addresses two pre-existing CodeRabbit findings (not rename artifacts).

CSV export silently truncated at 100 rows (Major)

handle_export() requested per_page => 10000, but Ettic_OTC_Chat_Log::query() clamps per_page with min(100, …) to protect the admin list view. Any questions log with >100 rows exported only the most recent 100.

Fix: keep the 100-row query cap, but page through results in the export handler until the full filtered set is written.

frontend.js null guards (Minor)

Two click handlers dereferenced DOM lookups that assume sibling/container markup always exists (card.querySelector, text.classList). If markup drifts they throw and break later interactions. Added null guards.

🤖 Generated with Claude Code

Summary by CodeRabbit

Bug Fixes

  • Prevented runtime errors when interacting with certain UI elements by adding defensive checks.
  • Fixed CSV export to paginate correctly and export complete data sets instead of partial results.

Documentation

  • Updated translation/template metadata timestamps and source references for Dutch localization.

Review Change Stack

Export now pages through chat-log query (100/page cap) instead of
requesting per_page=10000 that query() silently clamped to 100.
Add null guards before two DOM dereferences in click handlers.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 864efddb-64b7-44fc-92d9-6cd3e061da0d

📥 Commits

Reviewing files that changed from the base of the PR and between 54aa008 and 72eb506.

📒 Files selected for processing (2)
  • languages/open-trust-center-by-ettic-nl_NL.po
  • languages/open-trust-center-by-ettic.pot
✅ Files skipped from review due to trivial changes (2)
  • languages/open-trust-center-by-ettic-nl_NL.po
  • languages/open-trust-center-by-ettic.pot

📝 Walkthrough

Walkthrough

Adds null-safety guards to frontend click handlers, changes admin CSV export to paginate through all chat log results, and updates POT/PO metadata timestamps and source reference line numbers.

Changes

Frontend DOM Safety Checks

Layer / File(s) Summary
DOM element null-safety guards
assets/js/frontend.js
The "View N more" overflow handler now checks that the surrounding card exists before querying the overflow list; the clamp toggle click handler verifies previousElementSibling exists and returns early if missing.

Backend CSV Export Pagination

Layer / File(s) Summary
Paginated CSV export implementation
includes/class-ettic-otc-admin-questions.php
CSV export now loops calls to Ettic_OTC_Chat_Log::query with page and per_page = 100, writes each page's rows to the CSV, and stops when the exported count matches total or a short final page is reached.

i18n PO/POT Metadata Updates

Layer / File(s) Summary
PO/POT header and source reference updates
languages/open-trust-center-by-ettic-nl_NL.po, languages/open-trust-center-by-ettic.pot
Updated POT-Creation-Date timestamps and adjusted autogenerated source reference line numbers for existing messages; translation texts (msgid/msgstr) are unchanged in the shown hunks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit peeks at DOM and rows,
Guards the clicks where mischief grows,
Pages hum and CSVs flow,
Timestamps tick where translations go,
Hops away—review done, let's go!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix CSV export truncation + frontend JS null guards' directly and accurately summarizes the two main changes: the CSV export pagination fix and the frontend JavaScript null safety improvements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/export-truncation-and-js-guards

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

@r00bbert r00bbert merged commit a3b6c3f into main May 21, 2026
11 checks passed
@r00bbert r00bbert deleted the fix/export-truncation-and-js-guards branch May 21, 2026 21:00
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.

1 participant