Skip to content

Commit

Permalink
Add search by status (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Jan 30, 2025
1 parent fda5a0e commit 784db8c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions server/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 22 additions & 7 deletions server/src/database/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -169,6 +174,7 @@ function help(searchText) {
label,
slug,
scriptingName,
status,
limit;

const dateMatch = searchText.match(
Expand All @@ -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+)/);
Expand Down Expand Up @@ -249,6 +259,10 @@ function help(searchText) {
slug = slugMatch[1].trim();
}

if (statusMatch) {
status = statusMatch[1].trim();
}

if (scriptingNameMatch) {
scriptingName = scriptingNameMatch[1].trim();
}
Expand All @@ -266,6 +280,7 @@ function help(searchText) {
label,
slug,
scriptingName,
status,
limit
};
}
3 changes: 3 additions & 0 deletions server/views/search.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 784db8c

Please sign in to comment.