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 {
author?: string;
copyright?: string;
}
/**
* Represents a structured filter derived from the freeform query.
*/
interface AdvancedFilter {
field: 'author' | 'copyright';
field: 'author';
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 } {
const tokens = query.split(/\s+/);
@@ -135,13 +134,6 @@ export class SearchService {
}
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);
}
@@ -161,7 +153,7 @@ export class SearchService {
const metadata = this.getCachedMetadata(file);
return filters.every((filter) => {
const source = filter.field === 'author' ? metadata.author : metadata.copyright;
const source = metadata.author;
if (!source) {
return false;
}
@@ -180,8 +172,7 @@ export class SearchService {
const metadata = this.tagService.readMetadata(file.absolutePath);
const normalized: CachedMetadata = {
author: metadata.author?.trim() || undefined,
copyright: metadata.copyright?.trim() || undefined
author: metadata.author?.trim() || undefined
};
this.metadataCache.set(file.id, normalized);
return normalized;

View File

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