Improve metadata quality assessment with new Metadata Match Score and filtering feature
This commit is contained in:
committed by
Aditya Chandel
parent
986599a913
commit
49b56b78e9
+64
@@ -0,0 +1,64 @@
|
||||
<div class="flex pb-8">
|
||||
<p class="text-lg flex items-center gap-2">
|
||||
Recalculate Metadata Scores:
|
||||
<i
|
||||
class="pi pi-info-circle text-blue-500"
|
||||
pTooltip="Recomputes match scores for all books based on the latest weights."
|
||||
tooltipPosition="right"
|
||||
style="cursor: help;"
|
||||
></i>
|
||||
</p>
|
||||
|
||||
<p-button
|
||||
class="pl-4"
|
||||
type="button"
|
||||
icon="pi pi-refresh"
|
||||
label="Recalculate"
|
||||
[disabled]="isRecalculating"
|
||||
(click)="recalculate()"
|
||||
outlined
|
||||
></p-button>
|
||||
</div>
|
||||
|
||||
|
||||
<p class="text-lg flex items-center gap-2">
|
||||
Metadata Field Weights
|
||||
<i
|
||||
class="pi pi-info-circle text-blue-500"
|
||||
pTooltip="Adjust how important each metadata field is when computing match scores. Higher weights make fields more influential."
|
||||
tooltipPosition="right"
|
||||
style="cursor: help;"
|
||||
></i>
|
||||
</p>
|
||||
|
||||
<div class="flex flex-col space-y-6 p-4">
|
||||
<div class="p-4 space-y-4 max-w-4xl custom-border">
|
||||
<form [formGroup]="form">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-y-4 gap-x-6">
|
||||
@for (key of orderedKeys; track key) {
|
||||
<div class="flex items-center gap-2">
|
||||
<label class="capitalize w-full max-w-[150px]">
|
||||
{{ labelMap[key] }}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
pInputText
|
||||
[formControlName]="key"
|
||||
class="w-20 text-center"
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="mt-4 flex justify-end">
|
||||
<p-button
|
||||
type="button"
|
||||
label="Save"
|
||||
icon="pi pi-save"
|
||||
outlined
|
||||
[disabled]="isSaving"
|
||||
(click)="save()">
|
||||
</p-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
.custom-border {
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: var(--card-border);
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from '@angular/forms';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {MetadataMatchWeightsService} from '../../../metadata-match-weights-service';
|
||||
import {Button} from 'primeng/button';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AppSettingKey, AppSettings} from '../../../core/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-match-weights-component',
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
Button,
|
||||
InputText,
|
||||
Tooltip
|
||||
],
|
||||
templateUrl: './metadata-match-weights-component.html',
|
||||
styleUrl: './metadata-match-weights-component.scss'
|
||||
})
|
||||
export class MetadataMatchWeightsComponent implements OnInit {
|
||||
|
||||
readonly labelMap: Record<string, string> = {
|
||||
title: 'Title',
|
||||
subtitle: 'Subtitle',
|
||||
authors: 'Authors',
|
||||
description: 'Description',
|
||||
publisher: 'Publisher',
|
||||
publishedDate: 'Published Date',
|
||||
categories: 'Categories',
|
||||
coverImage: 'Cover Image',
|
||||
seriesName: 'Series Name',
|
||||
seriesNumber: 'Series Number',
|
||||
language: 'Language',
|
||||
isbn13: 'ISBN-13',
|
||||
isbn10: 'ISBN-10',
|
||||
pageCount: 'Page Count',
|
||||
amazonRating: 'Amazon Rating',
|
||||
amazonReviewCount: 'Amazon Rating # ',
|
||||
goodreadsRating: 'Goodreads Rating',
|
||||
goodreadsReviewCount: 'Goodreads Rating #',
|
||||
hardcoverRating: 'Hardcover Rating',
|
||||
hardcoverReviewCount: 'Hardcover Rating #'
|
||||
};
|
||||
|
||||
form!: FormGroup;
|
||||
isSaving = false;
|
||||
isRecalculating = false;
|
||||
|
||||
private weightsService = inject(MetadataMatchWeightsService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
private fb = inject(FormBuilder);
|
||||
|
||||
appSettings$: Observable<AppSettings | null> = this.appSettingsService.appSettings$;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.form = this.fb.group({
|
||||
title: [0, [Validators.required, Validators.min(0)]],
|
||||
subtitle: [0, [Validators.required, Validators.min(0)]],
|
||||
description: [0, [Validators.required, Validators.min(0)]],
|
||||
publisher: [0, [Validators.required, Validators.min(0)]],
|
||||
publishedDate: [0, [Validators.required, Validators.min(0)]],
|
||||
authors: [0, [Validators.required, Validators.min(0)]],
|
||||
categories: [0, [Validators.required, Validators.min(0)]],
|
||||
seriesName: [0, [Validators.required, Validators.min(0)]],
|
||||
seriesNumber: [0, [Validators.required, Validators.min(0)]],
|
||||
isbn13: [0, [Validators.required, Validators.min(0)]],
|
||||
isbn10: [0, [Validators.required, Validators.min(0)]],
|
||||
pageCount: [0, [Validators.required, Validators.min(0)]],
|
||||
language: [0, [Validators.required, Validators.min(0)]],
|
||||
amazonRating: [0, [Validators.required, Validators.min(0)]],
|
||||
amazonReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
goodreadsRating: [0, [Validators.required, Validators.min(0)]],
|
||||
goodreadsReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
hardcoverRating: [0, [Validators.required, Validators.min(0)]],
|
||||
hardcoverReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
coverImage: [0, [Validators.required, Validators.min(0)]],
|
||||
});
|
||||
this.appSettings$
|
||||
.pipe(filter((settings): settings is AppSettings => !!settings), take(1))
|
||||
.subscribe(settings => {
|
||||
if (settings.metadataMatchWeights) {
|
||||
this.form.patchValue(settings.metadataMatchWeights);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
get orderedKeys(): string[] {
|
||||
return Object.keys(this.labelMap);
|
||||
}
|
||||
|
||||
save(): void {
|
||||
if (this.form.invalid) return;
|
||||
|
||||
this.isSaving = true;
|
||||
|
||||
const payload = [
|
||||
{
|
||||
key: AppSettingKey.METADATA_MATCH_WEIGHTS,
|
||||
newValue: this.form.value
|
||||
}
|
||||
];
|
||||
|
||||
this.appSettingsService.saveSettings(payload).subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Saved',
|
||||
detail: 'Weights saved successfully'
|
||||
});
|
||||
this.isSaving = false;
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to save weights'
|
||||
});
|
||||
this.isSaving = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
recalculate(): void {
|
||||
this.isRecalculating = true;
|
||||
this.weightsService.recalculateAll().subscribe({
|
||||
next: () => {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: 'Recalculated',
|
||||
detail: 'All book match scores were recalculated successfully.'
|
||||
});
|
||||
this.isRecalculating = false;
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: 'Error',
|
||||
detail: 'Failed to recalculate match scores.'
|
||||
});
|
||||
this.isRecalculating = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+8
@@ -24,4 +24,12 @@
|
||||
</app-metadata-advanced-fetch-options>
|
||||
</div>
|
||||
|
||||
<div class="pb-4">
|
||||
<p-divider></p-divider>
|
||||
</div>
|
||||
|
||||
<div class="p-4 pt-4">
|
||||
<app-metadata-match-weights-component></app-metadata-match-weights-component>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
+3
-1
@@ -10,6 +10,7 @@ import {MessageService} from 'primeng/api';
|
||||
import {Observable} from 'rxjs';
|
||||
import {AppSettingKey, AppSettings} from '../../core/model/app-settings.model';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {MetadataMatchWeightsComponent} from '../global-preferences/metadata-match-weights-component/metadata-match-weights-component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-settings-component',
|
||||
@@ -19,7 +20,8 @@ import {filter, take} from 'rxjs/operators';
|
||||
MetadataProviderSettingsComponent,
|
||||
ReactiveFormsModule,
|
||||
Tooltip,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
MetadataMatchWeightsComponent
|
||||
],
|
||||
templateUrl: './metadata-settings-component.html',
|
||||
styleUrl: './metadata-settings-component.scss'
|
||||
|
||||
Reference in New Issue
Block a user