fix(server): memory lane title (#2772)

* fix(server): memory lane title

* feat: parallel requests

* pr feedback

* fix test

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Jason Rasmussen
2023-06-15 14:05:30 -04:00
committed by GitHub
parent 045bb855d2
commit 896645130b
14 changed files with 136 additions and 65 deletions

View File

@@ -11,6 +11,7 @@ import {
} from '@app/domain';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { DateTime } from 'luxon';
import { FindOptionsRelations, FindOptionsWhere, In, IsNull, Not, Repository } from 'typeorm';
import { AssetEntity, AssetType } from '../entities';
import OptionalBetween from '../utils/optional-between.util';
@@ -21,7 +22,7 @@ export class AssetRepository implements IAssetRepository {
constructor(@InjectRepository(AssetEntity) private repository: Repository<AssetEntity>) {}
getByDate(ownerId: string, date: Date): Promise<AssetEntity[]> {
// For reference of a correct approach althought slower
// For reference of a correct approach although slower
// let builder = this.repository
// .createQueryBuilder('asset')
@@ -36,14 +37,13 @@ export class AssetRepository implements IAssetRepository {
// .orderBy('asset.fileCreatedAt', 'DESC');
// return builder.getMany();
const tomorrow = new Date(date.getTime() + 24 * 60 * 60 * 1000);
return this.repository.find({
where: {
ownerId,
isVisible: true,
isArchived: false,
fileCreatedAt: OptionalBetween(date, tomorrow),
fileCreatedAt: OptionalBetween(date, DateTime.fromJSDate(date).plus({ day: 1 }).toJSDate()),
},
relations: {
exifInfo: true,