mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Adding support for 0 day ago number in date pattern search
This commit is contained in:
parent
b383b7f585
commit
5368b4ed4e
@ -758,8 +758,8 @@ export class SearchManager {
|
||||
tq.frequency === DatePatternFrequency.weeks_ago ||
|
||||
tq.frequency === DatePatternFrequency.days_ago)) {
|
||||
|
||||
if (!tq.agoNumber) {
|
||||
throw new Error('ago number is missing on date patter search query with frequency: ' + DatePatternFrequency[tq.frequency]);
|
||||
if (isNaN(tq.agoNumber)) {
|
||||
throw new Error('ago number is missing on date patter search query with frequency: ' + DatePatternFrequency[tq.frequency] + ', ago number: ' + tq.agoNumber);
|
||||
}
|
||||
const to = new Date();
|
||||
to.setHours(0, 0, 0, 0);
|
||||
|
@ -394,7 +394,7 @@ export class SearchQueryParser {
|
||||
str.startsWith(this.keywords.sameDay + '!:')) && {
|
||||
negate: true
|
||||
}),
|
||||
...(ago && {agoNumber: ago})
|
||||
...(!isNaN(ago) && {agoNumber: ago})
|
||||
} as DatePatternSearch;
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +133,11 @@ describe('SearchQueryParser', () => {
|
||||
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||
frequency: DatePatternFrequency.every_year
|
||||
} as DatePatternSearch);
|
||||
check({
|
||||
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||
frequency: DatePatternFrequency.days_ago,
|
||||
agoNumber: 0
|
||||
} as DatePatternSearch);
|
||||
check({
|
||||
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||
frequency: DatePatternFrequency.days_ago,
|
||||
|
Loading…
Reference in New Issue
Block a user