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.weeks_ago ||
|
||||||
tq.frequency === DatePatternFrequency.days_ago)) {
|
tq.frequency === DatePatternFrequency.days_ago)) {
|
||||||
|
|
||||||
if (!tq.agoNumber) {
|
if (isNaN(tq.agoNumber)) {
|
||||||
throw new Error('ago number is missing on date patter search query with frequency: ' + DatePatternFrequency[tq.frequency]);
|
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();
|
const to = new Date();
|
||||||
to.setHours(0, 0, 0, 0);
|
to.setHours(0, 0, 0, 0);
|
||||||
|
@ -394,7 +394,7 @@ export class SearchQueryParser {
|
|||||||
str.startsWith(this.keywords.sameDay + '!:')) && {
|
str.startsWith(this.keywords.sameDay + '!:')) && {
|
||||||
negate: true
|
negate: true
|
||||||
}),
|
}),
|
||||||
...(ago && {agoNumber: ago})
|
...(!isNaN(ago) && {agoNumber: ago})
|
||||||
} as DatePatternSearch;
|
} as DatePatternSearch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,11 @@ describe('SearchQueryParser', () => {
|
|||||||
type: SearchQueryTypes.date_pattern, daysLength: i,
|
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||||
frequency: DatePatternFrequency.every_year
|
frequency: DatePatternFrequency.every_year
|
||||||
} as DatePatternSearch);
|
} as DatePatternSearch);
|
||||||
|
check({
|
||||||
|
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||||
|
frequency: DatePatternFrequency.days_ago,
|
||||||
|
agoNumber: 0
|
||||||
|
} as DatePatternSearch);
|
||||||
check({
|
check({
|
||||||
type: SearchQueryTypes.date_pattern, daysLength: i,
|
type: SearchQueryTypes.date_pattern, daysLength: i,
|
||||||
frequency: DatePatternFrequency.days_ago,
|
frequency: DatePatternFrequency.days_ago,
|
||||||
|
Loading…
Reference in New Issue
Block a user