mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-02 18:59:15 -05:00 
			
		
		
		
	* Exclude archived assets from search-explore #4041 * Update test to properly expect an empty array with archived items * typesense changes wip * Add isArchived filter to default search filters * Bump assets typesense schema version * fix(server): sync bug for bulk asset update --------- Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
This commit is contained in:
		
							parent
							
								
									0a22e64799
								
							
						
					
					
						commit
						69c23aa3ec
					
				@ -306,6 +306,7 @@ export class AssetService {
 | 
				
			|||||||
  async updateAll(authUser: AuthUserDto, dto: AssetBulkUpdateDto) {
 | 
					  async updateAll(authUser: AuthUserDto, dto: AssetBulkUpdateDto) {
 | 
				
			||||||
    const { ids, ...options } = dto;
 | 
					    const { ids, ...options } = dto;
 | 
				
			||||||
    await this.access.requirePermission(authUser, Permission.ASSET_UPDATE, ids);
 | 
					    await this.access.requirePermission(authUser, Permission.ASSET_UPDATE, ids);
 | 
				
			||||||
 | 
					    await this.jobRepository.queue({ name: JobName.SEARCH_INDEX_ASSET, data: { ids } });
 | 
				
			||||||
    await this.assetRepository.updateAll(ids, options);
 | 
					    await this.assetRepository.updateAll(ids, options);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -150,7 +150,7 @@ export class TypesenseRepository implements ISearchRepository {
 | 
				
			|||||||
  async explore(userId: string): Promise<SearchExploreItem<AssetEntity>[]> {
 | 
					  async explore(userId: string): Promise<SearchExploreItem<AssetEntity>[]> {
 | 
				
			||||||
    const common = {
 | 
					    const common = {
 | 
				
			||||||
      q: '*',
 | 
					      q: '*',
 | 
				
			||||||
      filter_by: this.buildFilterBy('ownerId', userId, true),
 | 
					      filter_by: [this.buildFilterBy('ownerId', userId, true), this.buildFilterBy('isArchived', false)].join(' && '),
 | 
				
			||||||
      per_page: 100,
 | 
					      per_page: 100,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -172,10 +172,7 @@ export class TypesenseRepository implements ISearchRepository {
 | 
				
			|||||||
                const config = {
 | 
					                const config = {
 | 
				
			||||||
                  ...common,
 | 
					                  ...common,
 | 
				
			||||||
                  query_by: 'originalFileName',
 | 
					                  query_by: 'originalFileName',
 | 
				
			||||||
                  filter_by: [
 | 
					                  filter_by: [common.filter_by, this.buildFilterBy(facet.field_name, count.value, true)].join(' && '),
 | 
				
			||||||
                    this.buildFilterBy('ownerId', userId, true),
 | 
					 | 
				
			||||||
                    this.buildFilterBy(facet.field_name, count.value, true),
 | 
					 | 
				
			||||||
                  ].join(' && '),
 | 
					 | 
				
			||||||
                  per_page: 1,
 | 
					                  per_page: 1,
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -468,7 +465,7 @@ export class TypesenseRepository implements ISearchRepository {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  private getAssetFilters(filters: SearchFilter) {
 | 
					  private getAssetFilters(filters: SearchFilter) {
 | 
				
			||||||
    const { userId } = filters;
 | 
					    const { userId } = filters;
 | 
				
			||||||
    const _filters = [this.buildFilterBy('ownerId', userId, true)];
 | 
					    const _filters = [this.buildFilterBy('ownerId', userId, true), this.buildFilterBy('isArchived', false)];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (filters.id) {
 | 
					    if (filters.id) {
 | 
				
			||||||
      _filters.push(this.buildFilterBy('id', filters.id, true));
 | 
					      _filters.push(this.buildFilterBy('id', filters.id, true));
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import { CollectionCreateSchema } from 'typesense/lib/Typesense/Collections';
 | 
					import { CollectionCreateSchema } from 'typesense/lib/Typesense/Collections';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const assetSchemaVersion = 9;
 | 
					export const assetSchemaVersion = 10;
 | 
				
			||||||
export const assetSchema: CollectionCreateSchema = {
 | 
					export const assetSchema: CollectionCreateSchema = {
 | 
				
			||||||
  name: `assets-v${assetSchemaVersion}`,
 | 
					  name: `assets-v${assetSchemaVersion}`,
 | 
				
			||||||
  fields: [
 | 
					  fields: [
 | 
				
			||||||
@ -13,6 +13,7 @@ export const assetSchema: CollectionCreateSchema = {
 | 
				
			|||||||
    { name: 'fileCreatedAt', type: 'string', facet: false, sort: true },
 | 
					    { name: 'fileCreatedAt', type: 'string', facet: false, sort: true },
 | 
				
			||||||
    { name: 'fileModifiedAt', type: 'string', facet: false, sort: true },
 | 
					    { name: 'fileModifiedAt', type: 'string', facet: false, sort: true },
 | 
				
			||||||
    { name: 'isFavorite', type: 'bool', facet: true },
 | 
					    { name: 'isFavorite', type: 'bool', facet: true },
 | 
				
			||||||
 | 
					    { name: 'isArchived', type: 'bool', facet: true },
 | 
				
			||||||
    { name: 'originalFileName', type: 'string', facet: false, optional: true },
 | 
					    { name: 'originalFileName', type: 'string', facet: false, optional: true },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // exif
 | 
					    // exif
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user