getSearchQueryString: add "time_filter" option
This commit is contained in:
parent
2cc049bb83
commit
a9cae23d87
3 changed files with 17 additions and 0 deletions
6
flow-typed/search.js
vendored
6
flow-typed/search.js
vendored
|
@ -18,6 +18,12 @@ declare type SearchOptions = {
|
||||||
SORT_ACCENDING: string,
|
SORT_ACCENDING: string,
|
||||||
SORT_DESCENDING: string,
|
SORT_DESCENDING: string,
|
||||||
EXACT: string,
|
EXACT: string,
|
||||||
|
TIME_FILTER: string,
|
||||||
|
TIME_FILTER_LAST_HOUR: string,
|
||||||
|
TIME_FILTER_TODAY: string,
|
||||||
|
TIME_FILTER_THIS_WEEK: string,
|
||||||
|
TIME_FILTER_THIS_MONTH: string,
|
||||||
|
TIME_FILTER_THIS_YEAR: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
declare type SearchState = {
|
declare type SearchState = {
|
||||||
|
|
|
@ -25,4 +25,10 @@ export const SEARCH_OPTIONS = {
|
||||||
SORT_ACCENDING: '^release_time',
|
SORT_ACCENDING: '^release_time',
|
||||||
SORT_DESCENDING: 'release_time',
|
SORT_DESCENDING: 'release_time',
|
||||||
EXACT: 'exact',
|
EXACT: 'exact',
|
||||||
|
TIME_FILTER: 'time_filter',
|
||||||
|
TIME_FILTER_LAST_HOUR: 'lasthour',
|
||||||
|
TIME_FILTER_TODAY: 'today',
|
||||||
|
TIME_FILTER_THIS_WEEK: 'thisweek',
|
||||||
|
TIME_FILTER_THIS_MONTH: 'thismonth',
|
||||||
|
TIME_FILTER_THIS_YEAR: 'thisyear',
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,6 +71,11 @@ export const getSearchQueryString = (query: string, options: any = {}) => {
|
||||||
if (sortBy) {
|
if (sortBy) {
|
||||||
queryParams.push(`${SEARCH_OPTIONS.SORT}=${sortBy}`);
|
queryParams.push(`${SEARCH_OPTIONS.SORT}=${sortBy}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const timeFilter = options[SEARCH_OPTIONS.TIME_FILTER];
|
||||||
|
if (timeFilter) {
|
||||||
|
queryParams.push(`${SEARCH_OPTIONS.TIME_FILTER}=${timeFilter}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const additionalOptions = {};
|
const additionalOptions = {};
|
||||||
|
|
Loading…
Reference in a new issue