Skip to content

feat: Trier feeds par date contenu#201

Merged
mtlaso merged 11 commits intomasterfrom
trii
Jun 30, 2025
Merged

feat: Trier feeds par date contenu#201
mtlaso merged 11 commits intomasterfrom
trii

Conversation

@mtlaso
Copy link
Copy Markdown
Owner

@mtlaso mtlaso commented Jun 29, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced feed timeline display with detailed content counts and improved menu interaction.
    • Newsletters are now retrieved through a dedicated method for more accurate presentation.
  • Bug Fixes

    • Feed timeline and menu components correctly reflect content counts and feed statuses.
  • Refactor

    • Feed and newsletter components updated to utilize refined data structures.
    • Timeline rendering simplified for improved clarity and performance.
  • Chores

    • Internal data fetching and synchronization processes optimized for better reliability and maintainability.

@vercel
Copy link
Copy Markdown

vercel bot commented Jun 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
bocal ⬜️ Ignored (Inspect) Visit Preview Jun 30, 2025 5:08am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 29, 2025

Walkthrough

This update refactors feed and newsletter data handling across UI and backend modules. It replaces the single getUserFeeds function with specialized functions for timelines, content counts, and newsletters. Corresponding UI components and types are updated to use new data structures, and the feed synchronization logic is revised to operate on feed IDs. Schema and type definitions are aligned with these changes.

Changes

Files / Grouped Paths Change Summary
src/app/[locale]/(app)/d/feeds/page.tsx Updated imports and logic to use new timeline and content count functions/components for feeds.
src/app/[locale]/(app)/d/newsletters/page.tsx Changed newsletter fetch to use new getUserNewsletters function.
src/app/[locale]/lib/dal.ts Replaced getUserFeeds with getUserFeedsTimeline, getUserFeedsWithContentsCount, and getUserNewsletters. Updated DAL exports.
src/app/[locale]/lib/feed-service.ts Rewrote triggerBackgroundSync to operate on feed IDs and handle missing feeds.
src/app/[locale]/lib/types.ts Added new type FeedWithContentsCount.
src/app/[locale]/ui/feeds/feed-context-menu.tsx Added "use client" directive for Next.js client-side rendering.
src/app/[locale]/ui/feeds/feed-info-context-menu.tsx Changed prop type from Feed[] to FeedWithContentsCount[]; updated URL copying logic.
src/app/[locale]/ui/feeds/feeds-info-menu.tsx Renamed and refactored component to use timeline and content count props; updated logic accordingly.
src/app/[locale]/ui/feeds/feeds-timeline.tsx Renamed and refactored component to use FeedTimeline[] for rendering.
src/app/[locale]/ui/newsletters/newsletter-item.tsx Changed prop types from FeedWithContent to Feed.
src/app/[locale]/ui/newsletters/newsletters.tsx Changed prop type from FeedWithContent[] to Feed[]; updated className logic.
src/db/schema.ts Replaced and renamed types and schemas for feed timeline; removed composite feed/content types.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI Component
    participant DAL as Data Access Layer
    participant DB as Database

    UI->>DAL: getUserFeedsTimeline()
    DAL->>DB: Query feeds, users_feeds, feeds_content, users_feeds_read_content
    DB-->>DAL: Timeline data
    DAL-->>UI: FeedTimeline[]

    UI->>DAL: getUserFeedsWithContentsCount()
    DAL->>DB: Query feeds, users_feeds, feeds_content (grouped by feed)
    DB-->>DAL: Feeds with content counts
    DAL-->>UI: FeedWithContentsCount[]

    UI->>DAL: getUserNewsletters()
    DAL->>DB: Query feeds filtered by newsletter ownership
    DB-->>DAL: Newsletters
    DAL-->>UI: Feed[]

    UI->>DAL: triggerBackgroundSync([feedIds])
    loop For each feedId
        DAL->>DB: Fetch feed by ID
        DB-->>DAL: Feed data
        DAL->>FeedParser: Parse feed URL
        FeedParser-->>DAL: New content, title
        DAL->>DB: Update feed, insert new content
    end
Loading

Poem

In the warren, feeds hop in a line,
Timelines and counts—oh, how they shine!
Newsletters now fetch with a single bound,
Types and schemas all tightly wound.
Syncing by ID, not by name,
This rabbit’s code will never be the same!
🐇✨


📜 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 c77cddc and f4033c2.

📒 Files selected for processing (2)
  • src/app/[locale]/lib/dal.ts (2 hunks)
  • src/app/[locale]/lib/feed-service.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app/[locale]/lib/feed-service.ts
  • src/app/[locale]/lib/dal.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Create Neon Branch
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18daaad and c77cddc.

📒 Files selected for processing (12)
  • src/app/[locale]/(app)/d/feeds/page.tsx (2 hunks)
  • src/app/[locale]/(app)/d/newsletters/page.tsx (1 hunks)
  • src/app/[locale]/lib/dal.ts (2 hunks)
  • src/app/[locale]/lib/feed-service.ts (2 hunks)
  • src/app/[locale]/lib/types.ts (1 hunks)
  • src/app/[locale]/ui/feeds/feed-context-menu.tsx (1 hunks)
  • src/app/[locale]/ui/feeds/feed-info-context-menu.tsx (2 hunks)
  • src/app/[locale]/ui/feeds/feeds-info-menu.tsx (5 hunks)
  • src/app/[locale]/ui/feeds/feeds-timeline.tsx (1 hunks)
  • src/app/[locale]/ui/newsletters/newsletter-item.tsx (2 hunks)
  • src/app/[locale]/ui/newsletters/newsletters.tsx (1 hunks)
  • src/db/schema.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
src/app/[locale]/ui/feeds/feed-context-menu.tsx (2)
Learnt from: mtlaso
PR: mtlaso/bocal#98
File: src/app/[locale]/(app)/feed/page.tsx:54-54
Timestamp: 2025-04-08T06:37:10.493Z
Learning: React's `cache()` function imported from 'react' is specifically designed for Server Components in Next.js and doesn't require the "use client" directive. It's used to deduplicate data fetching calls within a single request and can only be used in Server Components, not Client Components.
Learnt from: mtlaso
PR: mtlaso/bocal#98
File: src/app/[locale]/(app)/feed/page.tsx:54-54
Timestamp: 2025-04-08T06:37:10.493Z
Learning: React's `cache` function imported from 'react' can be used in Next.js server components without requiring "use client" directive. It's specifically designed to deduplicate data requests in server components.
src/app/[locale]/lib/dal.ts (2)
Learnt from: mtlaso
PR: mtlaso/bocal#176
File: src/app/[locale]/lib/actions.ts:739-745
Timestamp: 2025-06-18T09:37:41.932Z
Learning: In the codebase using Drizzle ORM, DELETE queries using `db.delete().where()` work without requiring the `.execute()` method call at the end. Both `await db.delete(feeds).where(...)` and `await db.delete(feeds).where(...).execute()` are valid patterns.
Learnt from: mtlaso
PR: mtlaso/bocal#176
File: src/app/[locale]/lib/dal.ts:127-131
Timestamp: 2025-06-18T09:35:19.881Z
Learning: In Drizzle ORM, sql.raw() works correctly within quoted strings inside sql tagged template literals. The pattern `sql`AND f.URL LIKE '${sql.raw(constant)}%'`` is valid and functional - the ${} placeholders are processed by Drizzle's SQL processor, not JavaScript string interpolation, so sql.raw() is properly handled even within quoted contexts.
🧬 Code Graph Analysis (5)
src/app/[locale]/(app)/d/newsletters/page.tsx (1)
src/app/[locale]/lib/dal.ts (1)
  • dal (210-216)
src/app/[locale]/ui/feeds/feed-info-context-menu.tsx (2)
src/app/[locale]/lib/types.ts (1)
  • FeedWithContentsCount (1-7)
src/app/[locale]/lib/userfeeds-funcs.ts (1)
  • userfeedsfuncs (52-56)
src/app/[locale]/ui/newsletters/newsletters.tsx (3)
src/db/schema.ts (1)
  • Feed (337-337)
src/lib/utils.ts (1)
  • cn (4-6)
src/app/[locale]/ui/spacing.ts (1)
  • SPACING (1-7)
src/app/[locale]/ui/feeds/feeds-timeline.tsx (4)
src/db/schema.ts (1)
  • FeedTimeline (338-338)
src/app/[locale]/lib/stores/search-params-states.ts (1)
  • searchParamsState (35-42)
src/lib/utils.ts (1)
  • cn (4-6)
src/app/[locale]/ui/spacing.ts (1)
  • SPACING (1-7)
src/app/[locale]/lib/dal.ts (6)
src/db/schema.ts (6)
  • FeedTimeline (338-338)
  • feedsTimelineSchema (334-334)
  • feeds (72-99)
  • feedsContent (104-124)
  • usersFeeds (129-140)
  • Feed (337-337)
src/db/db.ts (1)
  • db (24-24)
src/app/[locale]/lib/logging.ts (1)
  • logger (34-38)
src/app/[locale]/lib/feed-service.ts (1)
  • feedService (352-360)
src/app/[locale]/lib/types.ts (1)
  • FeedWithContentsCount (1-7)
src/app/[locale]/lib/userfeeds-funcs.ts (1)
  • userfeedsfuncs (52-56)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Create Neon Branch
🔇 Additional comments (24)
src/app/[locale]/lib/types.ts (1)

1-7: LGTM! Well-structured type definition.

The new FeedWithContentsCount type is cleanly defined with appropriate field types and follows TypeScript naming conventions. The structure aligns well with the feed data refactoring mentioned in the PR summary.

src/app/[locale]/ui/feeds/feed-context-menu.tsx (1)

1-1: Correct addition of client directive.

The "use client" directive is appropriately added since this component uses client-side React features like useTransition, toast notifications, and user interaction handlers.

src/app/[locale]/(app)/d/newsletters/page.tsx (1)

52-52: Approve: Specialized newsletter fetch method verified

  • Confirmed getUserNewsletters is defined in src/app/[locale]/lib/dal.ts and returns a Promise<Feed[]>.
  • No remaining calls to getUserFeeds with a newsletters filter.
  • This refactoring cleanly replaces the generic feed call with a dedicated newsletter method.

All good to merge.

src/app/[locale]/ui/newsletters/newsletter-item.tsx (2)

31-31: Type update aligns with refactoring.

The import change from FeedWithContent to Feed is consistent with the broader refactoring described in the PR summary.


33-33: No action required: Feed type includes all required properties

The Feed model inferred from src/db/schema.ts includes id, eid, url, and title (among other fields), so no changes are needed here.

src/app/[locale]/ui/newsletters/newsletters.tsx (2)

4-5: Consistent type and utility updates.

The changes align well with the refactoring:

  • Import updated from FeedWithContent to Feed type
  • Added cn utility for better class composition
  • Prop type updated consistently

Also applies to: 8-8


14-14: Improved styling with proper class composition.

Good use of the cn utility to combine Tailwind classes with the spacing constant. The new flex layout ("flex flex-col gap-4") with SPACING.MD should provide better visual organization.

src/app/[locale]/ui/feeds/feed-info-context-menu.tsx (3)

9-10: LGTM: Type and import updates are consistent with the refactor.

The type change from Feed[] to FeedWithContentsCount[] and the addition of userfeedsfuncs import align with the broader refactoring effort. These changes maintain type safety while supporting the new data structure.


22-22: LGTM: Props type correctly updated.

The props type change to FeedWithContentsCount[] is consistent with the new data structure and matches the import on line 9.


108-108: LGTM: URL formatting enhancement.

The addition of userfeedsfuncs.formatFeedURL(url) before copying to clipboard is a good enhancement that ensures consistent URL formatting. This aligns with the utility function imported on line 10.

src/app/[locale]/(app)/d/feeds/page.tsx (3)

7-8: LGTM: Component imports updated for refactored architecture.

The import changes from FeedInfoMenu/Feeds to FeedsInfoMenu/FeedsTimeline correctly reflect the component renaming and refactored data structure approach.


56-65: LGTM: Efficient parallel data fetching with proper prop distribution.

The refactor to fetch getUserFeedsTimeline and getUserFeedsWithContentsCount concurrently using Promise.all is efficient and aligns with the new data structure. The props are correctly passed to the FeedsInfoMenu component.


69-70: LGTM: Simplified data fetching for timeline component.

The FeedsWrapper correctly fetches only the timeline data needed for the FeedsTimeline component, maintaining separation of concerns.

src/app/[locale]/ui/feeds/feeds-timeline.tsx (4)

17-17: LGTM: Component renamed and properly typed for timeline structure.

The component name change from Feeds to FeedsTimeline and the type change to FeedTimeline[] correctly reflect the new timeline-based data structure.

Also applies to: 22-22, 25-25


30-33: LGTM: Filtering logic correctly updated for timeline structure.

The filtering logic properly adapts to the new timeline structure by filtering on el.feedId instead of the previous nested structure. The logic maintains the same behavior for selected feed filtering.


37-41: LGTM: Simplified rendering approach for timeline items.

The rendering logic is correctly simplified for the flat timeline structure. The null check for item.content is appropriate, and the direct mapping eliminates the previous nested iteration complexity.


45-45: LGTM: Item component type correctly updated.

The Item component's prop type is correctly updated from FeedContentWithReadAt to FeedTimeline, maintaining type consistency with the new data structure.

src/db/schema.ts (2)

325-332: LGTM: Well-structured timeline schema with comprehensive feed metadata.

The feedTimeline schema correctly extends the existing feedsContent schema and adds essential feed metadata fields (feedTitle, feedUrl, feedErrorType, feedLastSyncAt). The nullable feedErrorType and coerced date types are appropriately typed.


334-334: LGTM: Consistent schema and type exports for timeline structure.

The feedsTimelineSchema array export and FeedTimeline type export properly support the new timeline-based data structure and replace the removed composite types.

Also applies to: 338-338

src/app/[locale]/ui/feeds/feeds-info-menu.tsx (3)

7-7: LGTM: Component renamed and props properly structured for dual data sources.

The component rename to FeedsInfoMenu and the new props structure accepting both timeline and userFeedsWithContentsCount correctly implement the separation of timeline and content count data. The type imports are consistent with the new data structures.

Also applies to: 19-19, 23-25, 27-30


34-34: LGTM: Efficient data usage and calculation simplification.

The assignment of feeds from userFeedsWithContentsCount and the use of timeline.length for total content calculation properly leverage the new data structure while simplifying the logic.

Also applies to: 53-53


143-143: LGTM: Prop type and content count display correctly updated.

The FeedMenuItem component's prop type change to FeedWithContentsCount and the use of feed.contentsCount instead of feed.contents.length properly adapt to the new data structure and provide the same functionality.

Also applies to: 176-176

src/app/[locale]/lib/dal.ts (2)

138-168: LGTM!

The function correctly implements feed retrieval with content counts using proper joins and grouping.


170-205: LGTM!

The function correctly filters and returns user newsletters with appropriate authorization checks.

@github-actions
Copy link
Copy Markdown

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