1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Adding indexes and proper character set to Media metadata to improve search performance

This commit is contained in:
Patrik J. Braun 2021-05-12 12:35:16 +02:00
parent 872e63703d
commit 09230b9e55
4 changed files with 27 additions and 3 deletions

View File

@ -54,6 +54,7 @@ export class DirectoryEntity implements DirectoryDTO {
@OneToMany(type => DirectoryEntity, dir => dir.parent)
public directories: DirectoryEntity[];
// not saving to database, it is only assigned when querying the DB
public preview: MediaEntity;
@OneToMany(type => MediaEntity, media => media.directory)

View File

@ -17,12 +17,19 @@ export class MediaDimensionEntity implements MediaDimension {
export class MediaMetadataEntity implements MediaMetadata {
@Index()
@Column('text')
caption: string;
@Column(type => MediaDimensionEntity)
size: MediaDimensionEntity;
/**
* Date in local timezone
* Reason: If you look back your holiday photos from a different timezone,
* you do not want to see 2AM next to a photo that was taken during lunch
*/
@Column('bigint', {
unsigned: true, transformer: {
from: v => parseInt(v, 10),
@ -34,6 +41,7 @@ export class MediaMetadataEntity implements MediaMetadata {
@Column('int', {unsigned: true})
fileSize: number;
@Index()
@Column({
type: 'simple-array',
charset: columnCharsetCS.charset,
@ -47,6 +55,7 @@ export class MediaMetadataEntity implements MediaMetadata {
@Column(type => PositionMetaDataEntity)
positionData: PositionMetaDataEntity;
@Index()
@Column('tinyint', {unsigned: true})
rating: 0 | 1 | 2 | 3 | 4 | 5;
@ -56,12 +65,16 @@ export class MediaMetadataEntity implements MediaMetadata {
@OneToMany(type => FaceRegionEntry, faceRegion => faceRegion.media)
faces: FaceRegionEntry[];
/**
* Caches the list of persons. Only used for searching
*/
@Index()
@Column({
type: 'simple-array', select: false, nullable: true,
charset: columnCharsetCS.charset,
collation: columnCharsetCS.collation
})
persons: string[]; // Caches the list of persons. Only used for searching
persons: string[];
@Column('int', {unsigned: true})
bitRate: number;
@ -81,6 +94,7 @@ export abstract class MediaEntity implements MediaDTO {
@PrimaryGeneratedColumn({unsigned: true})
id: number;
@Index()
@Column(columnCharsetCS)
name: string;

View File

@ -1,6 +1,7 @@
import {ChildEntity, Column} from 'typeorm';
import {ChildEntity, Column, Index} from 'typeorm';
import {CameraMetadata, GPSMetadata, PhotoDTO, PhotoMetadata, PositionMetaData} from '../../../../../common/entities/PhotoDTO';
import {MediaEntity, MediaMetadataEntity} from './MediaEntity';
import {columnCharsetCS} from './EntityUtils';
export class CameraMetadataEntity implements CameraMetadata {
@ -8,9 +9,11 @@ export class CameraMetadataEntity implements CameraMetadata {
ISO: number;
@Column('text', {nullable: true})
@Column(columnCharsetCS)
model: string;
@Column('text', {nullable: true})
@Column(columnCharsetCS)
make: string;
@Column('float', {nullable: true})
@ -43,13 +46,19 @@ export class PositionMetaDataEntity implements PositionMetaData {
@Column(type => GPSMetadataEntity)
GPSData: GPSMetadataEntity;
@Index()
@Column('text', {nullable: true})
@Column(columnCharsetCS)
country: string;
@Index()
@Column('text', {nullable: true})
@Column(columnCharsetCS)
state: string;
@Index()
@Column('text', {nullable: true})
@Column(columnCharsetCS)
city: string;
}

View File

@ -1 +1 @@
export const DataStructureVersion = 19;
export const DataStructureVersion = 20;