diff --git a/server/locales/en.json b/server/locales/en.json index a1c8b47..8f568c0 100644 --- a/server/locales/en.json +++ b/server/locales/en.json @@ -60,6 +60,7 @@ "search.help.bybrowser": "Find tests by browser: chrome, firefox, edge, safari", "search.help.byscriptname": "Find tests by script name", "search.help.bylocation": "Find tests by location", + "search.help.bystatus": "Find tests by status", "search.help.bytesttype": "Find tests by test type: desktop, emulatedMobile or android.", "search.help.byurl": "Find tests by a URL. The URL must start with http and the search will do an equal match. If you want to search partial URLS use the url: command.", "search.help.byurlwithwildcard":"Find tests by a URL. The URL will wildcard search the beginning and end of the URL so you can use it to search for part of a URL. For example %s will match %s", diff --git a/server/src/database/search.js b/server/src/database/search.js index ea73958..8e27fea 100644 --- a/server/src/database/search.js +++ b/server/src/database/search.js @@ -143,6 +143,11 @@ function generateMatch(parameters) { parameters_.push(parameters.testType); } + if (parameters.status) { + where.push('status = $' + (parameters_.length + 1)); + parameters_.push(parameters.status); + } + if (parameters.before) { where.push('DATE(run_date) < $' + (parameters_.length + 1)); parameters_.push(parameters.before); @@ -169,6 +174,7 @@ function help(searchText) { label, slug, scriptingName, + status, limit; const dateMatch = searchText.match( @@ -177,30 +183,34 @@ function help(searchText) { const beforeMatch = searchText.match(/before:\s*(\d{4}-\d{2}-\d{2})/); const afterMatch = searchText.match(/after:\s*(\d{4}-\d{2}-\d{2})/); const whenMatch = searchText.match( - /when:\s*(.*?)(?=(date:|before:|after:|testType:|browser:|name:|slug:|label:|http|$))/s + /when:\s*(.*?)(?=(date:|before:|after:|testType:|browser:|name:|slug:|status:|label:|http|$))/s ); const locationMatch = searchText.match( - /location:\s*(.*?)(?=(date:|before:|after:|testType:|browser:|name:|label:|slug:|w:|when:|http|$))/s + /location:\s*(.*?)(?=(date:|before:|after:|testType:|browser:|name:|label:|slug:|status:|w:|when:|http|$))/s ); const urlMatchPerfect = searchText.match(/(http\S*)/); const urlMatch = searchText.match( - /url:\s*(.*?)(?=(date:|before:|after:|location:|browser:|name:|label:|slug:|when:|$))/s + /url:\s*(.*?)(?=(date:|before:|after:|location:|browser:|name:|label:|slug:|status:|when:|$))/s ); const testTypeMatch = searchText.match( - /testType:\s*(.*?)(?=(date:|before:|after:|location:|browser:|name:|label:|slug:|when:|http|$))/s + /testType:\s*(.*?)(?=(date:|before:|after:|location:|browser:|name:|label:|slug:|status:|when:|http|$))/s ); const browserMatch = searchText.match( - /browser:\s*(.*?)(?=(date:|before:|after:|location:|testType:|name:|label:|slug:|when:|http|$))/s + /browser:\s*(.*?)(?=(date:|before:|after:|location:|testType:|name:|label:|slug:|status:|when:|http|$))/s ); const labelMatch = searchText.match( /label:\s*(.*?)(?=(date:|before:|after:|location:|testType:|browser:|name:|when:|http|$))/s ); const scriptingNameMatch = searchText.match( - /name:\s*(.*?)(?=(date:|before:|after:|location:|testType:|browser:|label:|slug:|when:|http|$))/s + /name:\s*(.*?)(?=(date:|before:|after:|location:|testType:|browser:|label:|slug:|status:|when:|http|$))/s ); const slugMatch = searchText.match( - /slug:\s*(.*?)(?=(date:|before:|after:|location:|testType:|browser:|name:|when:|http|$))/s + /slug:\s*(.*?)(?=(date:|before:|after:|location:|testType:|browser:|name:|when:|status:|http|$))/s + ); + + const statusMatch = searchText.match( + /status:\s*(.*?)(?=(date:|before:|after:|location:|testType:|browser:|name:|slug:|when:|http|$))/s ); const limitMatch = searchText.match(/limit:\s*(\d+)/); @@ -249,6 +259,10 @@ function help(searchText) { slug = slugMatch[1].trim(); } + if (statusMatch) { + status = statusMatch[1].trim(); + } + if (scriptingNameMatch) { scriptingName = scriptingNameMatch[1].trim(); } @@ -266,6 +280,7 @@ function help(searchText) { label, slug, scriptingName, + status, limit }; } diff --git a/server/views/search.pug b/server/views/search.pug index 53f3a51..c5532ec 100644 --- a/server/views/search.pug +++ b/server/views/search.pug @@ -114,6 +114,9 @@ block content li b name: | - #{getText('search.help.byscriptname')} + li + b status: + | - #{getText('search.help.bystatus')} if data if data.count > 0