Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
etnoy committed Jan 20, 2025
1 parent 24de62f commit ca55d4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import { anyUuid, asUuid, mapUpsertColumns } from 'src/utils/database';
import { globToSqlPattern } from 'src/utils/misc';
import { Paginated, PaginationOptions, paginationHelper } from 'src/utils/pagination';

const ASSET_CUTOFF_DATE = new Date('9000-01-01');

@Injectable()
export class AssetRepository implements IAssetRepository {
constructor(@InjectKysely() private db: Kysely<DB>) {}
Expand Down Expand Up @@ -527,6 +529,7 @@ export class AssetRepository implements IAssetRepository {
return this.db
.selectFrom('assets')
.selectAll('assets')
.where('assets.fileCreatedAt', '<=', ASSET_CUTOFF_DATE)
.$call(withExif)
.where('ownerId', '=', anyUuid(userIds))
.where('isVisible', '=', true)
Expand All @@ -543,6 +546,7 @@ export class AssetRepository implements IAssetRepository {
.with('assets', (qb) =>
qb
.selectFrom('assets')
.where('assets.fileCreatedAt', '<=', ASSET_CUTOFF_DATE)
.select(truncatedDate<Date>(options.size).as('timeBucket'))
.$if(!!options.isTrashed, (qb) => qb.where('assets.status', '!=', AssetStatus.DELETED))
.where('assets.deletedAt', options.isTrashed ? 'is not' : 'is', null)
Expand Down Expand Up @@ -592,6 +596,7 @@ export class AssetRepository implements IAssetRepository {
async getTimeBucket(timeBucket: string, options: TimeBucketOptions): Promise<AssetEntity[]> {
return hasPeople(this.db, options.personId ? [options.personId] : undefined)
.selectAll('assets')
.where('assets.fileCreatedAt', '<=', ASSET_CUTOFF_DATE)
.$call(withExif)
.$if(!!options.albumId, (qb) => withAlbums(qb, { albumId: options.albumId }))
.$if(!!options.userIds, (qb) => qb.where('assets.ownerId', '=', anyUuid(options.userIds!)))
Expand Down
8 changes: 5 additions & 3 deletions server/src/services/library.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { mimeTypes } from 'src/utils/mime-types';
import { handlePromiseError } from 'src/utils/misc';
import { usePagination } from 'src/utils/pagination';

const ASSET_IMPORT_DATE = new Date('9999-12-31');

@Injectable()
export class LibraryService extends BaseService {
private watchLibraries = false;
Expand Down Expand Up @@ -378,9 +380,9 @@ export class LibraryService extends BaseService {
checksum: this.cryptoRepository.hashSha1(`path:${assetPath}`),
originalPath: assetPath,

fileCreatedAt: new Date(),
fileModifiedAt: new Date(),
localDateTime: new Date(),
fileCreatedAt: ASSET_IMPORT_DATE,
fileModifiedAt: ASSET_IMPORT_DATE,
localDateTime: ASSET_IMPORT_DATE,
// TODO: device asset id is deprecated, remove it
deviceAssetId: `${basename(assetPath)}`.replaceAll(/\s+/g, ''),
deviceId: 'Library Import',
Expand Down
4 changes: 2 additions & 2 deletions server/src/services/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ export class MetadataService extends BaseService {
let fileCreatedAtDate = dateTimeOriginal;
let fileModifiedAtDate = modifyDate;

/* if (asset.isExternal) {
if (asset.isExternal) {
fileCreatedAtDate = fileCreatedAt;
fileModifiedAtDate = fileModifiedAt;
} */
}

const exifData: Insertable<Exif> = {
assetId: asset.id,
Expand Down

0 comments on commit ca55d4f

Please sign in to comment.