Skip to content

Commit

Permalink
Add last hour search button (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Jun 27, 2024
1 parent 838fd0e commit edf2878
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"index.waitingtorunnext": "Waiting to run next.",
"index.inqueue": "There are %s jobs in the queue and your job is place %s in the queue",

"search.button.lasthour": "Last hour",
"search.button.today": "Today",
"search.button.yesterday": "Yesterday",
"search.button.lastweek": "Last week",
Expand Down
5 changes: 5 additions & 0 deletions server/src/database/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ function generateMatch(parameters) {

if (parameters.when) {
switch (parameters.when) {
case 'lasthour': {
where.push('run_date >= $' + (parameters_.length + 1));
parameters_.push(dayjs().subtract(1, 'hour').toISOString());
break;
}
case 'today': {
where.push('DATE(run_date) = $' + (parameters_.length + 1));
parameters_.push(dayjs().format('YYYY-MM-DD'));
Expand Down
1 change: 1 addition & 0 deletions server/views/search.pug
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ block content
button.button.is-primary.is-large(accesskey='s' name='searchbutton') #{getText('search.button.search')}
p.control
.buttons.py-2
button.button.is-primary.is-medium(onclick='addToSearch(\'when:lasthour\')' role='button') #{getText('search.button.lasthour')}
button.button.is-primary.is-medium(onclick='addToSearch(\'when:today\')' role='button') #{getText('search.button.today')}
button.button.is-primary.is-medium(onclick='addToSearch(\'when:yesterday\')' role='button') #{getText('search.button.yesterday')}
button.button.is-primary.is-medium(onclick='addToSearch(\'when:lastweek\')' role='button') #{getText('search.button.lastweek')}
Expand Down

0 comments on commit edf2878

Please sign in to comment.