Skip to content

Enhance Slack integration and database backup workflows#21

Merged
wpak-ai merged 3 commits intodevelopfrom
feat/fix-db-backup
May 8, 2026
Merged

Enhance Slack integration and database backup workflows#21
wpak-ai merged 3 commits intodevelopfrom
feat/fix-db-backup

Conversation

@wpak-ai
Copy link
Copy Markdown
Contributor

@wpak-ai wpak-ai commented May 8, 2026

Summary by CodeRabbit

  • New Features

    • Posts Slack status summary once at startup when a notification channel is configured.
    • DB backups now run in parallel for staging and production, using environment-scoped secrets and environment-specific backup paths/unique keys.
  • Documentation

    • Clarified Slack Request URL for reverse-proxy path prefixes.
    • Updated deployment and backup/restore docs for new GCS bucket/path naming and restore examples.
  • Tests

    • Added coverage for status message formatting and startup enqueue behavior.
  • Chores

    • Updated .gitignore to ignore .cursor.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0b5efb5f-ab37-4f08-9771-a797eeb7398f

📥 Commits

Reviewing files that changed from the base of the PR and between b516b2c and 69e3df9.

📒 Files selected for processing (2)
  • .github/workflows/db-backup.yml
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/db-backup.yml

📝 Walkthrough

Walkthrough

Adds startup Slack-status enqueueing at process boot and converts the GitHub Actions DB backup to a staging/production matrix that uploads environment-scoped dumps to gs://insights-db-backups/paperscout//; documentation and tests updated accordingly.

Changes

Startup Status Notification

Layer / File(s) Summary
Core Implementation
src/paperscout/scout.py
format_status_message(state, paper_count_fn) and enqueue_startup_status(mq, state, paper_count_fn) added; _handle_status delegates to the formatter.
Entrypoint Integration
src/paperscout/__main__.py
Imports and calls enqueue_startup_status(mq, state, paper_count_fn) after Slack Bolt starts and before scheduler loop.
Tests
tests/test_scout.py
Adds TestFormatStatusMessage and TestEnqueueStartupStatus covering formatter parity and conditional enqueueing.
Changelog
CHANGELOG.md
Documents startup Slack status posting in Unreleased section.

Database Backup Parallelization

Layer / File(s) Summary
Workflow Configuration
.github/workflows/db-backup.yml
backup job uses strategy.matrix.environment: [staging, production], sets environment: ${{ matrix.environment }}, parameterizes step name, and computes environment-scoped dump names and DEST GCS paths under gs://insights-db-backups/paperscout/${{ matrix.environment }}/....
Deployment Documentation
deploy/SERVER_SETUP.md
Restore/download examples updated to use environment-scoped GCS paths and pg_restore --no-owner; repo clone URL and staging-host example added; secrets/environments guidance consolidated.
General Documentation
README.md, docs/onboarding.md
Clarifies Slack Request URL when behind nginx path-prefix and documents the new matrix backup workflow and architecture notes.
Configuration & Changelog
.gitignore, CHANGELOG.md
Adds .cursor to .gitignore and updates changelog entries describing workflow and deployment URL changes.

Sequence Diagram(s)

sequenceDiagram
  participant Main as __main__
  participant MQ as MessageQueue
  participant Scout as scout
  participant Slack as NOTIFICATION_CHANNEL
  Main->>Scout: enqueue_startup_status(mq, state, paper_count_fn)
  Scout->>Scout: format_status_message(...)
  Scout->>MQ: enqueue(message)
  MQ->>Slack: post formatted status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

documentation

Poem

🐰 I trimmed the startup note and set backups two-by-two,
Staging hops left, production bounces through.
Messages queued at dawn, a gentle, punctual tap —
Dumps tucked in GCS, each in its own map.
The rabbit files a changelog, then takes a nap.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely missing; no content was provided by the author. Add a description following the template with a summary of changes, confirmation of test plan execution, and any related issue links.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Enhance Slack integration and database backup workflows' is clear and accurately describes the main changes across multiple areas of the codebase.
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 feat/fix-db-backup

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/db-backup.yml:
- Around line 27-33: The STAMP/DUMP/DEST naming is too coarse and can collide;
change how STAMP, DUMP and DEST are constructed so they include the environment
(matrix.environment) plus a unique run identifier (e.g. GITHUB_RUN_ID or
GITHUB_RUN_NUMBER) and/or a random suffix or use a safe temporary filename
generator for DUMP (instead of fixed /tmp/paperscout-${STAMP}.dump). Update the
DUMP variable (used by sudo -u postgres pg_dump) to use that unique temp name
and update DEST (gs://.../paperscout/${{ matrix.environment }}/...) to include
the same unique run id so uploaded object keys are unique per run and per
environment.

In `@deploy/SERVER_SETUP.md`:
- Around line 240-243: The pg_restore invocation shown for restoring paperscout
omits the --no-owner flag; update the pg_restore command (the line containing
"pg_restore -U paperscout -h localhost -d paperscout -c /tmp/paperscout.dump")
to include --no-owner (i.e., add the --no-owner option alongside -c) so the
restore mirrors the earlier examples and avoids ownership-related failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: de02fba6-fb94-4a0a-bb0b-5b320053720a

📥 Commits

Reviewing files that changed from the base of the PR and between 8da43bf and 4366c75.

📒 Files selected for processing (9)
  • .github/workflows/db-backup.yml
  • .gitignore
  • CHANGELOG.md
  • README.md
  • deploy/SERVER_SETUP.md
  • docs/onboarding.md
  • src/paperscout/__main__.py
  • src/paperscout/scout.py
  • tests/test_scout.py

Comment thread .github/workflows/db-backup.yml Outdated
Comment thread deploy/SERVER_SETUP.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/db-backup.yml:
- Around line 26-34: The script may leave the temporary dump file if a command
fails because set -e skips the final rm; ensure cleanup always runs by
installing an EXIT trap immediately after defining DUMP that removes the file
(use a safe conditional that checks the DUMP variable exists before removing),
e.g. set the trap right after the DUMP assignment so any early failures invoke
the trap and remove the artifact; keep the existing rm -f "$DUMP" at the end
(harmless) and ensure the trap runs only once (or is idempotent).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c8fa1ca-a950-420d-806d-eaf056e6ca64

📥 Commits

Reviewing files that changed from the base of the PR and between 4366c75 and b516b2c.

📒 Files selected for processing (4)
  • .github/workflows/db-backup.yml
  • CHANGELOG.md
  • README.md
  • deploy/SERVER_SETUP.md
✅ Files skipped from review due to trivial changes (2)
  • README.md
  • deploy/SERVER_SETUP.md

Comment thread .github/workflows/db-backup.yml
…porary dump files on failure; update documentation for clarity on backup processes.
@wpak-ai wpak-ai merged commit b90a50e into develop May 8, 2026
7 checks passed
@wpak-ai wpak-ai deleted the feat/fix-db-backup branch May 8, 2026 17:44
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