mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Making autocompete item setting more fine tuned #660
This commit is contained in:
parent
42f17ac7af
commit
b1813d7258
@ -85,7 +85,7 @@ export class SearchManager {
|
|||||||
.where('photo.metadata.keywords LIKE :text COLLATE ' + SQL_COLLATE, {
|
.where('photo.metadata.keywords LIKE :text COLLATE ' + SQL_COLLATE, {
|
||||||
text: '%' + text + '%',
|
text: '%' + text + '%',
|
||||||
})
|
})
|
||||||
.limit(Config.Search.AutoComplete.targetItemsPerCategory * 2)
|
.limit(Config.Search.AutoComplete.ItemsPerCategory.keyword*2)
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
)
|
)
|
||||||
.map(
|
.map(
|
||||||
@ -120,7 +120,7 @@ export class SearchManager {
|
|||||||
text: '%' + text + '%',
|
text: '%' + text + '%',
|
||||||
})
|
})
|
||||||
.limit(
|
.limit(
|
||||||
Config.Search.AutoComplete.targetItemsPerCategory * 2
|
Config.Search.AutoComplete.ItemsPerCategory.person*2
|
||||||
)
|
)
|
||||||
.orderBy('person.count', 'DESC')
|
.orderBy('person.count', 'DESC')
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
@ -161,7 +161,7 @@ export class SearchManager {
|
|||||||
.groupBy(
|
.groupBy(
|
||||||
'photo.metadata.positionData.country, photo.metadata.positionData.state, photo.metadata.positionData.city'
|
'photo.metadata.positionData.country, photo.metadata.positionData.state, photo.metadata.positionData.city'
|
||||||
)
|
)
|
||||||
.limit(Config.Search.AutoComplete.targetItemsPerCategory * 2)
|
.limit(Config.Search.AutoComplete.ItemsPerCategory.position*2)
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
)
|
)
|
||||||
.filter((pm): boolean => !!pm)
|
.filter((pm): boolean => !!pm)
|
||||||
@ -199,7 +199,7 @@ export class SearchManager {
|
|||||||
text: '%' + text + '%',
|
text: '%' + text + '%',
|
||||||
})
|
})
|
||||||
.limit(
|
.limit(
|
||||||
Config.Search.AutoComplete.targetItemsPerCategory * 2
|
Config.Search.AutoComplete.ItemsPerCategory.file_name*2
|
||||||
)
|
)
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
).map((r) => r.name),
|
).map((r) => r.name),
|
||||||
@ -223,7 +223,7 @@ export class SearchManager {
|
|||||||
{text: '%' + text + '%'}
|
{text: '%' + text + '%'}
|
||||||
)
|
)
|
||||||
.limit(
|
.limit(
|
||||||
Config.Search.AutoComplete.targetItemsPerCategory * 2
|
Config.Search.AutoComplete.ItemsPerCategory.caption*2
|
||||||
)
|
)
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
).map((r) => r.caption),
|
).map((r) => r.caption),
|
||||||
@ -246,7 +246,7 @@ export class SearchManager {
|
|||||||
text: '%' + text + '%',
|
text: '%' + text + '%',
|
||||||
})
|
})
|
||||||
.limit(
|
.limit(
|
||||||
Config.Search.AutoComplete.targetItemsPerCategory * 2
|
Config.Search.AutoComplete.ItemsPerCategory.directory*2
|
||||||
)
|
)
|
||||||
.getRawMany()
|
.getRawMany()
|
||||||
).map((r) => r.name),
|
).map((r) => r.name),
|
||||||
@ -260,13 +260,13 @@ export class SearchManager {
|
|||||||
// if not enough items are available, load more from one category
|
// if not enough items are available, load more from one category
|
||||||
if (
|
if (
|
||||||
[].concat(...partialResult).length <
|
[].concat(...partialResult).length <
|
||||||
Config.Search.AutoComplete.maxItems
|
Config.Search.AutoComplete.ItemsPerCategory.maxItems
|
||||||
) {
|
) {
|
||||||
result = [].concat(...partialResult);
|
result = [].concat(...partialResult);
|
||||||
} else {
|
} else {
|
||||||
result = [].concat(
|
result = [].concat(
|
||||||
...partialResult.map((l) =>
|
...partialResult.map((l) =>
|
||||||
l.slice(0, Config.Search.AutoComplete.targetItemsPerCategory)
|
l.slice(0, (Config.Search.AutoComplete.ItemsPerCategory as any)[SearchQueryTypes[l[0].type]])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,86 @@ export type TAGS = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@SubConfigClass<TAGS>({tags: {client: true}, softReadonly: true})
|
||||||
|
export class AutoCompleteItemsPerCategoryConfig {
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Maximum items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown at once. If there is not enough items to reach this value, it takes upto double of the individual items.`
|
||||||
|
})
|
||||||
|
maxItems: number = 30;
|
||||||
|
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Max photo items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown per photo category.`
|
||||||
|
})
|
||||||
|
file_name: number = 2;
|
||||||
|
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Max directory items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown per directory category.`
|
||||||
|
})
|
||||||
|
directory: number = 2;
|
||||||
|
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Max caption items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown per caption category.`
|
||||||
|
})
|
||||||
|
caption: number = 3;
|
||||||
|
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Max position items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown per position category.`
|
||||||
|
})
|
||||||
|
position: number = 3;
|
||||||
|
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Max faces items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown per faces category.`
|
||||||
|
})
|
||||||
|
person: number = 5;
|
||||||
|
|
||||||
|
@ConfigProperty({
|
||||||
|
type: 'unsignedInt',
|
||||||
|
tags:
|
||||||
|
{
|
||||||
|
name: $localize`Max keyword items`,
|
||||||
|
priority: ConfigPriority.underTheHood
|
||||||
|
},
|
||||||
|
description: $localize`Maximum number autocomplete items shown per keyword category.`
|
||||||
|
})
|
||||||
|
keyword: number = 5;
|
||||||
|
}
|
||||||
|
|
||||||
@SubConfigClass<TAGS>({tags: {client: true}, softReadonly: true})
|
@SubConfigClass<TAGS>({tags: {client: true}, softReadonly: true})
|
||||||
export class AutoCompleteConfig {
|
export class AutoCompleteConfig {
|
||||||
@ConfigProperty({
|
@ConfigProperty({
|
||||||
@ -69,8 +149,8 @@ export class AutoCompleteConfig {
|
|||||||
description: $localize`Show hints while typing search query.`
|
description: $localize`Show hints while typing search query.`
|
||||||
})
|
})
|
||||||
enabled: boolean = true;
|
enabled: boolean = true;
|
||||||
|
|
||||||
@ConfigProperty({
|
@ConfigProperty({
|
||||||
type: 'unsignedInt',
|
|
||||||
tags:
|
tags:
|
||||||
{
|
{
|
||||||
name: $localize`Max items per category`,
|
name: $localize`Max items per category`,
|
||||||
@ -78,17 +158,8 @@ export class AutoCompleteConfig {
|
|||||||
},
|
},
|
||||||
description: $localize`Maximum number autocomplete items shown per category.`
|
description: $localize`Maximum number autocomplete items shown per category.`
|
||||||
})
|
})
|
||||||
targetItemsPerCategory: number = 5;
|
ItemsPerCategory: AutoCompleteItemsPerCategoryConfig = new AutoCompleteItemsPerCategoryConfig();
|
||||||
@ConfigProperty({
|
|
||||||
type: 'unsignedInt',
|
|
||||||
tags:
|
|
||||||
{
|
|
||||||
name: $localize`Maximum items`,
|
|
||||||
priority: ConfigPriority.underTheHood
|
|
||||||
},
|
|
||||||
description: $localize`Maximum number autocomplete items shown at once.`
|
|
||||||
})
|
|
||||||
maxItems: number = 30;
|
|
||||||
@ConfigProperty({
|
@ConfigProperty({
|
||||||
type: 'unsignedInt',
|
type: 'unsignedInt',
|
||||||
tags:
|
tags:
|
||||||
@ -690,7 +761,7 @@ export class ClientGalleryConfig {
|
|||||||
name: $localize`Themes`,
|
name: $localize`Themes`,
|
||||||
priority: ConfigPriority.advanced,
|
priority: ConfigPriority.advanced,
|
||||||
} as TAGS,
|
} as TAGS,
|
||||||
description:$localize`Pigallery2 uses Bootstrap 5.3 (https://getbootstrap.com/docs/5.3) for design (css, layout). In dark mode it sets 'data-bs-theme="dark"' to the <html> to take advantage bootstrap's color modes. For theming, read more at: https://getbootstrap.com/docs/5.3/customize/color-modes/`
|
description: $localize`Pigallery2 uses Bootstrap 5.3 (https://getbootstrap.com/docs/5.3) for design (css, layout). In dark mode it sets 'data-bs-theme="dark"' to the <html> to take advantage bootstrap's color modes. For theming, read more at: https://getbootstrap.com/docs/5.3/customize/color-modes/`
|
||||||
})
|
})
|
||||||
Themes: ThemesConfig = new ThemesConfig();
|
Themes: ThemesConfig = new ThemesConfig();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user