Refactor SearchService: remove copyright field from CachedMetadata and AdvancedFilter

This commit is contained in:
2025-11-06 04:26:43 +11:00
parent c5185f2c70
commit 472939c7e2
2 changed files with 5 additions and 14 deletions

View File

@@ -8,14 +8,13 @@ import { TagService } from './TagService';
*/ */
interface CachedMetadata { interface CachedMetadata {
author?: string; author?: string;
copyright?: string;
} }
/** /**
* Represents a structured filter derived from the freeform query. * Represents a structured filter derived from the freeform query.
*/ */
interface AdvancedFilter { interface AdvancedFilter {
field: 'author' | 'copyright'; field: 'author';
value: string; value: string;
} }
@@ -119,7 +118,7 @@ export class SearchService {
} }
/** /**
* Pulls out author/copyright filters and returns the remaining free text query. * Pulls out author filters and returns the remaining free text query.
*/ */
private extractAdvancedFilters(query: string): { filters: AdvancedFilter[]; remainingQuery: string } { private extractAdvancedFilters(query: string): { filters: AdvancedFilter[]; remainingQuery: string } {
const tokens = query.split(/\s+/); const tokens = query.split(/\s+/);
@@ -135,13 +134,6 @@ export class SearchService {
} }
continue; continue;
} }
if (lower.startsWith('copyright:')) {
const value = token.slice('copyright:'.length).trim();
if (value.length > 0) {
filters.push({ field: 'copyright', value: value.toLowerCase() });
}
continue;
}
remainingTokens.push(token); remainingTokens.push(token);
} }
@@ -161,7 +153,7 @@ export class SearchService {
const metadata = this.getCachedMetadata(file); const metadata = this.getCachedMetadata(file);
return filters.every((filter) => { return filters.every((filter) => {
const source = filter.field === 'author' ? metadata.author : metadata.copyright; const source = metadata.author;
if (!source) { if (!source) {
return false; return false;
} }
@@ -180,8 +172,7 @@ export class SearchService {
const metadata = this.tagService.readMetadata(file.absolutePath); const metadata = this.tagService.readMetadata(file.absolutePath);
const normalized: CachedMetadata = { const normalized: CachedMetadata = {
author: metadata.author?.trim() || undefined, author: metadata.author?.trim() || undefined
copyright: metadata.copyright?.trim() || undefined
}; };
this.metadataCache.set(file.id, normalized); this.metadataCache.set(file.id, normalized);
return normalized; return normalized;

View File

@@ -2,7 +2,7 @@
"extends": "./tsconfig.base.json", "extends": "./tsconfig.base.json",
"compilerOptions": { "compilerOptions": {
"module": "CommonJS", "module": "CommonJS",
"moduleResolution": "Bundler", "moduleResolution": "Node",
"outDir": "dist/main", "outDir": "dist/main",
"rootDir": "src", "rootDir": "src",
"types": ["node"], "types": ["node"],