Skip to content

Conversation

@DDonochVA
Copy link
Contributor

@DDonochVA DDonochVA commented Sep 30, 2025

Summary by CodeRabbit

  • New Features

    • Added support for hidden articles: they remain excluded by default but can be included when explicitly requested (e.g., preview/admin).
    • Route generation and article listings can now return expanded results when hidden items are requested.
  • Chores

    • Backend and data layer updated to consistently honor the hidden status across queries and indexes.

@coderabbitai
Copy link

coderabbitai bot commented Sep 30, 2025

Walkthrough

Adds an isHidden boolean column to articles and articleCounts, updates multiple covering and unique indexes to include isHidden, modifies API queries to conditionally skip the isHidden=false filter when showHidden is present, and updates the build script to request articles with the showHidden flag.

Changes

Cohort / File(s) Summary
Build script route update
apps/blog/scripts/build-routes.mjs
Appends showHidden to the articles fetch URL (/articles?skip=...&take=...&showHidden), causing the script to request results that may include hidden articles.
API conditional hidden filter
libs/blog-bff/articles/api/src/lib/api.ts
Adds showHiddenFilter(table, showHidden) and spreads it into the where clauses for article fetch and count queries so the isHidden = false constraint is omitted when showHidden is present.
Schema column and index updates
libs/blog-bff/shared/schema/src/lib/schema.ts
Adds isHidden (mapped is_hidden, boolean, notNull) to articles and articleCounts; includes table.isHidden in multiple covering indexes and the composite unique index for articleCounts.

Sequence Diagram(s)

sequenceDiagram
  participant BuildScript as Build Routes Script
  participant API as Blog BFF Articles API
  participant DB as Database

  BuildScript->>API: GET /articles?skip=..&take=..&showHidden
  API->>API: Parse query -> showHidden present?
  alt showHidden present
    API->>DB: SELECT ... WHERE ... (no isHidden filter)
  else showHidden absent
    API->>DB: SELECT ... WHERE isHidden = false
  end
  DB-->>API: Rows + Count
  API-->>BuildScript: JSON response
  note over DB: Covering indexes updated to include isHidden
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my ears at hidden lore,
A flag appears behind the door.
Columns indexed, the queries play,
The API peeks or looks away.
I hop along—more posts today! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “feat: explicitly hide articles” concisely captures the primary feature introduced by this changeset, namely the addition of an explicit hiding mechanism for articles via the new isHidden flag and showHidden parameter in the API, and it avoids irrelevant details or noise.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/explicit-hidden-articles

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d829590 and a920e08.

📒 Files selected for processing (3)
  • apps/blog/scripts/build-routes.mjs (1 hunks)
  • libs/blog-bff/articles/api/src/lib/api.ts (4 hunks)
  • libs/blog-bff/shared/schema/src/lib/schema.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • libs/blog-bff/articles/api/src/lib/api.ts
  • libs/blog-bff/shared/schema/src/lib/schema.ts
🔇 Additional comments (1)
apps/blog/scripts/build-routes.mjs (1)

50-50: Verify: Should hidden articles be included in SSG routes and sitemap?

The showHidden parameter will include hidden articles in both the pre-rendered routes (routes.txt) and the sitemap. If hidden articles are meant to be inaccessible or unlisted, this could unintentionally expose them.

Please confirm:

  • Is it intended to pre-render hidden articles during the build?
  • Are there runtime access controls that prevent viewing hidden articles even when routes exist?
  • Should hidden articles be excluded from the sitemap for SEO purposes?

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.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
libs/blog-bff/shared/schema/src/lib/schema.ts (1)

146-167: articleCounts table missing isHidden column.

The articleCounts table doesn't include an isHidden column, but the API code at libs/blog-bff/articles/api/src/lib/api.ts line 68 attempts to filter on it. This will cause runtime errors when the count query is executed without the showHidden parameter.

Consider adding isHidden to the articleCounts table or adjusting the count query logic to work without it:

 export const articleCounts = sqliteTable(
   'article_counts',
   {
     lang: integer('lang').notNull(),
     status: integer('status').notNull(),
+    isHidden: integer('is_hidden', { mode: 'boolean' }).notNull(),
     isNews: integer('is_news', { mode: 'boolean' }).notNull(),
     isGuide: integer('is_guide', { mode: 'boolean' }).notNull(),
     isInDepth: integer('is_in_depth', { mode: 'boolean' }).notNull(),
     isRecommended: integer('is_recommended', { mode: 'boolean' }).notNull(),
     rowCount: integer('row_count').notNull(),
   },
   (table) => [
     unique().on(
       table.lang,
       table.status,
+      table.isHidden,
       table.isNews,
       table.isGuide,
       table.isInDepth,
       table.isRecommended,
     ),
   ],
 );
🧹 Nitpick comments (2)
libs/blog-bff/articles/api/src/lib/api.ts (1)

145-147: Consider requiring an explicit truthy value for showHidden parameter.

The current logic showHidden !== undefined means any query string value (including empty string like ?showHidden= or ?showHidden=false) will include hidden articles. This might be unexpected behavior.

Consider checking for an explicit truthy value:

-function showHiddenFilter(table: typeof articles, showHidden?: string) {
-  return showHidden !== undefined ? [] : [eq(table.isHidden, false)];
+function showHiddenFilter(table: typeof articles, showHidden?: string) {
+  return showHidden === 'true' || showHidden === '1' ? [] : [eq(table.isHidden, false)];
}
apps/blog/scripts/build-routes.mjs (1)

50-50: Query parameter value inconsistency.

The showHidden parameter is added without an explicit value (?showHidden), which will result in an empty string value in the API. The current API implementation treats any defined value (including empty string) as "show hidden", but this relies on implicit behavior.

Consider using an explicit value for clarity:

-  const url = `${API_BASE_URL}/articles?skip=${skip}&take=${take}&showHidden`;
+  const url = `${API_BASE_URL}/articles?skip=${skip}&take=${take}&showHidden=true`;

This makes the intent clearer and aligns better if the API is updated to check for truthy values.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e858eda and d829590.

📒 Files selected for processing (3)
  • apps/blog/scripts/build-routes.mjs (1 hunks)
  • libs/blog-bff/articles/api/src/lib/api.ts (3 hunks)
  • libs/blog-bff/shared/schema/src/lib/schema.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
libs/blog-bff/articles/api/src/lib/api.ts (1)
libs/blog-bff/shared/schema/src/lib/schema.ts (1)
  • articles (52-144)
🔇 Additional comments (5)
libs/blog-bff/articles/api/src/lib/api.ts (2)

86-122: Single article endpoint bypasses isHidden filter.

The /:slug endpoint retrieves articles without checking the isHidden flag, potentially exposing hidden articles to anyone who knows the slug. This might be intentional for preview purposes, but it creates an inconsistency with the listing endpoint.

Verify whether hidden articles should be accessible via direct slug lookup, or if the endpoint should respect the isHidden flag (or require authentication/authorization to view hidden articles).


53-53: Filter logic works correctly for article listing.

The spread operator correctly applies the hidden filter when showHidden is absent, maintaining backward compatibility while adding the new feature.

libs/blog-bff/shared/schema/src/lib/schema.ts (2)

102-142: Excellent index coverage for isHidden filtering.

All article-related covering indexes have been updated to include isHidden, ensuring efficient query performance when filtering by hidden status. The placement of isHidden early in the index (after status) is optimal for selective filtering.


77-77: Confirm migration sets default value for is_hidden.
No SQL or TS migration was found for this column; ensure existing rows are backfilled with false.

apps/blog/scripts/build-routes.mjs (1)

50-50: Verify build-time inclusion of hidden articles is intentional.

The build script now fetches all articles including hidden ones (showHidden parameter present). This means hidden articles will be pre-rendered during the build process and accessible via direct URLs, even though they won't appear in listings.

Confirm this is the intended behavior. If hidden articles should not be accessible at all (not even pre-rendered), consider:

  1. Removing the showHidden parameter here to exclude them from SSG
  2. Adding runtime checks in the article component to handle hidden articles
  3. Or implementing authentication/authorization for accessing hidden articles

If the intention is to use hidden articles as "unlisted" (accessible by direct link but not in listings), the current implementation is correct.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@DDonochVA DDonochVA force-pushed the feat/explicit-hidden-articles branch from d829590 to a920e08 Compare October 1, 2025 09:11
@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

1 similar comment
@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deploy failed, please check the logs in jenkins for more details.

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

4 similar comments
@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

PR is detected, will deploy to dev environment

@valueadd-robot
Copy link

Deployed to dev environment
Branch: feat/explicit-hidden-articles
BFF URL: https://cfbe101d-blog-bff-dev.contact-ef8.workers.dev
Deploy URL: https://1a27d400.angular-love-client.pages.dev
Alias URL: https://feat-explicit-hidden-article.angular-love-client.pages.dev

@DDonochVA DDonochVA merged commit 51a339c into main Oct 2, 2025
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 2, 2025
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.

3 participants