Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

Add timeline

Open ildyria opened this issue 6 months ago • 1 comments

This pull request introduces a comprehensive implementation of a timeline feature for photos, including backend logic, new enums, exceptions, and controller methods. The changes are organized into several themes: new timeline functionality, enhancements to enums, and updates to request handling and resources.

New Timeline Functionality

  • app/Actions/Photo/Timeline.php: Added a new Timeline class that provides methods for querying photos by timeline, counting photos based on date or photo reference, and retrieving distinct timeline dates. It supports granularities like year, month, day, and hour.
  • app/Http/Controllers/Gallery/TimelineController.php: Introduced a TimelineController to handle timeline-related requests, including fetching photos, initializing the timeline, and retrieving timeline dates.

Enhancements to Enums

  • app/Enum/TimelinePhotoGranularity.php and app/Enum/TimelineAlbumGranularity.php: Added a format method to both enums, allowing retrieval of ISO date formats based on granularity. [1] [2]
  • app/Exceptions/Internal/TimelineGranularityException.php: Added a new exception to handle invalid timeline granularities.

Updates to Request Handling and Resources

  • app/Http/Requests/Timeline/GetTimelineRequest.php and app/Http/Requests/Timeline/IdOrDatedTimelineRequest.php: Added new request classes for validating and processing timeline-related API inputs, including support for photo IDs and date-based queries. [1] [2]
  • app/Http/Resources/Models/Utils/TimelineData.php: Enhanced the TimelineData utility to support date-based timeline entries and handle granularities more robustly.
  • app/Http/Resources/Timeline/InitResource.php: Added an initialization resource for the timeline page, including configuration and rights information.

These changes collectively enable robust timeline functionality, supporting both granular and flexible date-based photo organization.

ildyria avatar Jun 13 '25 11:06 ildyria

Codecov Report

:x: Patch coverage is 70.12195% with 49 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 90.49%. Comparing base (92c808b) to head (d2eed6e). :warning: Report is 15 commits behind head on master.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 13 '25 11:06 codecov[bot]

📝 Walkthrough

Walkthrough

Adds a Timeline feature: new Timeline action, controller endpoints and routes, request validators, resources, enums and exception, config keys and migrations, middleware/route-cache updates, web route, and tests; supports configurable granularity, ordering, NSFW filtering, date/photo anchors, and cross-database date formatting.

Changes

Cohort / File(s) Change Summary
Timeline core action
app/Actions/Photo/Timeline.php
New Timeline class building timeline photo queries with eager loads, applying PhotoQueryPolicy and hide_nsfw_in_timeline, ordering by configured column with safe defaults, counting younger items by date/photo, and aggregating timeline dates by granularity with cross‑DB formatting.
Controllers & routes
app/Http/Controllers/Gallery/TimelineController.php, routes/api_v2.php, routes/web_v2.php
New Gallery timeline endpoints (/Timeline, /Timeline::dates, /Timeline::init) with cache_control; added web route /timeline/{date?}/{photoId?}.
Requests & attributes
app/Http/Requests/Timeline/GetTimelineRequest.php, app/Http/Requests/Timeline/IdOrDatedTimelineRequest.php, app/Contracts/Http/Requests/RequestAttribute.php
New GetTimelineRequest (authorization based on auth and configs) and IdOrDatedTimelineRequest (accepts photo ID or date; dynamic date_format validation by configured granularity; resolves Photo/Carbon); added DATE_ATTRIBUTE constant.
Resources & data shaping
app/Http/Resources/Timeline/InitResource.php, app/Http/Resources/Timeline/TimelineResource.php, app/Http/Resources/GalleryConfigs/InitConfig.php, app/Http/Resources/Models/Utils/TimelineData.php
New InitResource and TimelineResource (wraps paginated PhotoResource, sets prev/next ids); InitConfig exposes is_timeline_page_enabled; TimelineData::fromDate added, unified quick-access format keys used, and TimelineGranularityException applied for invalid granularities.
Enums & exception
app/Enum/TimelineAlbumGranularity.php, app/Enum/TimelinePhotoGranularity.php, app/Exceptions/Internal/TimelineGranularityException.php
Added format() to granularity enums returning PHP date formats; DEFAULT/DISABLED now throw TimelineGranularityException; new TimelineGranularityException class added.
Config integrity & route cache
app/Http/Middleware/ConfigIntegrity.php, app/Metadata/Cache/RouteCacheManager.php
SE_FIELDS extended with quick-access date format keys; RouteCacheManager registers Timeline routes and cache configs (init/dates user-dependent under SETTINGS).
Migrations / config seed
database/migrations/2025_06_13_121811_default_view_gallery_timeline.php, database/migrations/2025_06_13_122020_reorder_timeline_config.php
New migration seeding timeline config keys (enable flag and quick-access formats) and a migration reordering/categorizing timeline config entries with explicit orders and expert flags.
Tests
tests/Feature_v2/Timeline/TimelineTest.php
New feature tests verifying unauthorized vs public access to timeline endpoints, init payload contents, and date/photo parameter behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I nibble timestamps with velvet feet,
Grouping years and months into a sweet treat.
IDs and dates I hop between,
Stitching moments, neat and clean.
A tiny rabbit maps the timeline beat 🥕

[!TIP]

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled
  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between db12da27b5ff61bfa274fa6a63c814c4ffc7f569 and d2eed6e3bbc38264eb311f1b74e7d83308b3d8a8.

📒 Files selected for processing (1)
  • app/Http/Controllers/Gallery/TimelineController.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/Http/Controllers/Gallery/TimelineController.php
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: 3️⃣ PHP dist / 8.3 - sqlite
  • GitHub Check: 3️⃣ PHP dist / 8.3 - postgresql
  • GitHub Check: 3️⃣ PHP dist / 8.4 - sqlite
  • GitHub Check: 3️⃣ PHP dist / 8.4 - postgresql
  • GitHub Check: 3️⃣ PHP dist / 8.3 - mariadb
  • GitHub Check: 3️⃣ PHP dist / 8.4 - mariadb
  • GitHub Check: 2️⃣ PHP tests / 8.4 - sqlite -- Unit,Feature_v2
  • GitHub Check: 2️⃣ PHP tests / 8.3 - mariadb -- Unit,Feature_v2
  • GitHub Check: 2️⃣ PHP tests / 8.4 - postgresql -- Unit,Feature_v2
  • GitHub Check: 2️⃣ PHP tests / 8.3 - sqlite -- Unit,Feature_v2
  • GitHub Check: 2️⃣ PHP tests / 8.3 - postgresql -- Unit,Feature_v2
  • GitHub Check: 2️⃣ PHP tests / 8.4 - mariadb -- Unit,Feature_v2
✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch timeline/backend

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

coderabbitai[bot] avatar Aug 18 '25 16:08 coderabbitai[bot]