[BUG] memories shouldn't be limited to 30 years and should use more efficient query #947

Closed
opened 2026-02-20 00:00:03 -05:00 by deekerman · 1 comment
Owner

Originally created by @uhthomas on GitHub (Jun 15, 2023).

The bug

Per my comment on the initial memories PR, memories shouldn't be limited to just 30 years and should use a more efficient query, rather than 30 queries.

@jrasm91 Wrote an initial implementation of the query which seems to work.

return this.repository.find({
  where: {
    ownerId,
    isVisible: true,
    isArchived: false,
    fileCreatedAt: Raw(
      (alias) =>
        `EXTRACT(MONTH FROM ${alias} AT TIME ZONE :timeZone) = :month AND EXTRACT(DAY FROM ${alias} AT TIME ZONE :timeZone) = :day`,
      {
        day: date.getDate(),
        month: date.getMonth() + 1,
        timeZone: date.getHours(),
      },
    ),
  },
  relations: {
    exifInfo: true,
  },
  order: {
    fileCreatedAt: 'DESC',
  },
});

The OS that Immich Server is running on

N/A

Version of Immich Server

N/A

Version of Immich Mobile App

N/A

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

N/A

Your .env content

N/A

Reproduction steps

N/A

Additional information

No response

Originally created by @uhthomas on GitHub (Jun 15, 2023). ### The bug Per [my comment](https://github.com/immich-app/immich/pull/2759#discussion_r1230226011) on the initial memories PR, memories shouldn't be limited to just 30 years and should use a more efficient query, rather than 30 queries. @jrasm91 Wrote an initial implementation of the query which seems to work. ```ts return this.repository.find({ where: { ownerId, isVisible: true, isArchived: false, fileCreatedAt: Raw( (alias) => `EXTRACT(MONTH FROM ${alias} AT TIME ZONE :timeZone) = :month AND EXTRACT(DAY FROM ${alias} AT TIME ZONE :timeZone) = :day`, { day: date.getDate(), month: date.getMonth() + 1, timeZone: date.getHours(), }, ), }, relations: { exifInfo: true, }, order: { fileCreatedAt: 'DESC', }, }); ``` ### The OS that Immich Server is running on N/A ### Version of Immich Server N/A ### Version of Immich Mobile App N/A ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML N/A ``` ### Your .env content ```Shell N/A ``` ### Reproduction steps ```bash N/A ``` ### Additional information _No response_
deekerman 2026-02-20 00:00:03 -05:00
Author
Owner

@alextran1502 commented on GitHub (Oct 4, 2023):

Fixed

@alextran1502 commented on GitHub (Oct 4, 2023): Fixed
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/immich#947
No description provided.