Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search by status #128

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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