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 advanced search #873

Merged
merged 1 commit into from
May 7, 2024
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 TestResultSummaryService/routes/getTestBySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ searchOutputId = async (build) => {
testResult: test.testResult,
duration: test.duration,
machine: build.machine,
timestamp: build.timestamp,
};
});
}
Expand Down
48 changes: 48 additions & 0 deletions TestResultSummaryService/routes/getTestByTestName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { TestResultsDB, ObjectID } = require('../Database');
module.exports = async (req, res) => {
const { testName, buildNames, beforeTimestamp } = req.query;
const db = new TestResultsDB();
let query = {};
if (buildNames) {
const buildNameArray = buildNames.split(',');
const rootBuildIds = [];
await Promise.all(
buildNameArray.map(async (buildName) => {
const buildData = await db.getData({ buildName }).toArray();
buildData.forEach((build) => {
rootBuildIds.push(new ObjectID(build._id));
});
})
);
query.rootBuildId = { $in: rootBuildIds };
}
if (beforeTimestamp) {
query.timestamp = { $lt: parseInt(beforeTimestamp) };
}
const history = await db.aggregate([
{
$match: query,
},
{ $unwind: '$tests' },
{
$match: {
'tests.testName': testName,
},
},
{
$project: {
parentId: 1,
buildName: 1,
buildNum: 1,
machine: 1,
buildUrl: 1,
tests: 1,
timestamp: 1,
javaVersion: 1,
},
},
{ $sort: { timestamp: -1 } },
]);

res.send(history);
};
13 changes: 13 additions & 0 deletions TestResultSummaryService/routes/getTestNames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { TestResultsDB, ObjectID } = require('../Database');
module.exports = async (req, res) => {
const testResultsDB = new TestResultsDB();
const data = await testResultsDB.aggregate([
{ $group: { _id: '$tests.testName' } },
{ $unwind: '$_id' },
{ $group: { _id: '$_id' } },
{ $sort: { _id: 1 } },
]);
testNames = data.map(({ _id }) => _id);

res.send(testNames);
};
2 changes: 2 additions & 0 deletions TestResultSummaryService/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ app.get('/getTestBuildsByMachine', wrap(require('./getTestBuildsByMachine')));
app.get('/getTestById', wrap(require('./getTestById')));
app.get('/getTestBySearch', wrap(require('./getTestBySearch')));
app.get('/getTestByVersionInfo', wrap(require('./getTestByVersionInfo')));
app.get('/getTestNames', wrap(require('./getTestNames')));
app.get('/getTestByTestName', wrap(require('./getTestByTestName')));
app.get('/getTestPerPlatform', wrap(require('./getTestPerPlatform')));
app.get('/getTopLevelBuildNames', wrap(require('./getTopLevelBuildNames')));
app.get('/getTotals', wrap(require('./getTotals')));
Expand Down
85 changes: 85 additions & 0 deletions test-result-summary-client/src/AdvancedSearch/AdvancedSearch.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React, { Component } from 'react';
import { Space, Button } from 'antd';
import { fetchData } from '../utils/Utils';
import InputAutoComplete from './InputAutoComplete';
import InputSelect from './InputSelect';
import SearchTestResult from '../Search/SearchTestResult';

export default class AdvancedSearch extends Component {
constructor(props) {
super(props);
this.state = {
testName: '',
testNameOptions: [],
buildNameOptions: [],
};
}
async componentDidMount() {
await this.updateData();
}

async updateData() {
const data = await fetchData(`/api/getTopLevelBuildNames?type=Test`);
let buildNames = [];
if (data) {
buildNames = data.map((value) => {
return value._id.buildName;
});
}
const testNames = await fetchData(`/api/getTestNames`);

this.setState({
buildNameOptions: buildNames.sort(),
testNameOptions: testNames,
});
}
handleSubmit = async () => {
const { testName, buildNames } = this.state;
const buildNamesStr = buildNames.join(',');
const data = await fetchData(
`/api/getTestByTestName?testName=${testName}&buildNames=${buildNamesStr}`
);

const result = data.map((element) => ({
...element,
...element.tests,
}));

this.setState({ result });
};
onBuildNameChange = (value) => {
this.setState({ buildNames: value });
};

onTestNameChange = (value) => {
this.setState({ testName: value });
};
onSelect = (value) => {
this.setState({ value });
};
render() {
const { buildNameOptions, testNameOptions, testName, result } =
this.state;
return (
<Space direction="vertical">
<InputAutoComplete
value={testName}
options={testNameOptions}
onSelect={this.onSelect}
onChange={this.onTestNameChange}
message="please input test name"
/>
<InputSelect
options={buildNameOptions}
onChange={this.onBuildNameChange}
message="please select build name"
/>
<Button type="primary" onClick={this.handleSubmit}>
Search
</Button>
<br />
{result ? <SearchTestResult tests={result} /> : ''}
</Space>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { Component } from 'react';
import { AutoComplete } from 'antd';

export default class InputAutoComplete extends Component {
render() {
return (
<AutoComplete
value={this.props.value}
options={this.props.options.map((value) => ({ value }))}
style={{
width: 600,
}}
onSelect={this.props.onSelect}
onChange={this.props.onChange}
placeholder={this.props.message}
filterOption={(inputValue, option) =>
option.value
.toUpperCase()
.includes(inputValue.toUpperCase())
}
/>
);
}
}
20 changes: 20 additions & 0 deletions test-result-summary-client/src/AdvancedSearch/InputSelect.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { Component } from 'react';
import { Select } from 'antd';

export default class InoutSelect extends Component {
render() {
const options = this.props.options.map((value) => ({ value }));
return (
<Select
mode="multiple"
allowClear
style={{
width: '100%',
}}
placeholder={this.props.message}
onChange={this.props.onChange}
options={options}
/>
);
}
}
1 change: 1 addition & 0 deletions test-result-summary-client/src/AdvancedSearch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as AdvancedSearch } from './AdvancedSearch';
124 changes: 99 additions & 25 deletions test-result-summary-client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { TestCompare } from './TestCompare/';
import { ThirdPartyAppView } from './ThirdPartyAppView/';
import { PerfCompare } from './PerfCompare/';
import { TabularView } from './TabularView/';
import { AdvancedSearch } from './AdvancedSearch/';

import {
AllTestsInfo,
BuildDetail,
Expand Down Expand Up @@ -96,23 +98,23 @@ export default class App extends Component {
),
},
{
key: '6',
key: '2',
label: (
<Link to="/tests/AQAvitCert">
AQAvit Verification
</Link>
),
},
{
key: '2',
key: '3',
label: (
<Link to="/testCompare">
Test Compare
</Link>
),
},
{
key: '3',
key: '4',
label: 'Perf Related',
children: [
{
Expand Down Expand Up @@ -142,21 +144,29 @@ export default class App extends Component {
],
},
{
key: '4',
key: '5',
label: (
<Link to="/dashboard">
Dashboard
</Link>
),
},
{
key: '5',
key: '6',
label: (
<Link to="/ThirdPartyAppView">
Third Party Applications
</Link>
),
},
{
key: '7',
label: (
<Link to="/AdvancedSearch">
Advanced Search
</Link>
),
},
]}
/>
</Sider>
Expand All @@ -171,26 +181,90 @@ export default class App extends Component {
}}
>
<Routes>
<Route path="/" element={<TopLevelBuilds />} />
<Route path="/admin/settings" element={<Settings />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/tests/:type" element={<TopLevelBuilds />} />
<Route path="/output/:outputType" element={<Output />} />
<Route path="/deepHistory" element={<DeepHistory />} />
<Route path="/gitNewIssue" element={<GitNewIssue />} />
<Route path="/testCompare" element={<TestCompare />} />
<Route path="/perfCompare" element={<PerfCompare />} />
<Route path="/tabularView" element={<TabularView />} />
<Route path="/buildDetail" element={<BuildDetail />} />
<Route path="/buildTreeView" element={<BuildTreeView />} />
<Route path="/builds" element={<Builds />} />
<Route path="/allTestsInfo" element={<AllTestsInfo />} />
<Route path="/testPerPlatform" element={<TestPerPlatform />} />
<Route path="/possibleIssues" element={<PossibleIssues />} />
<Route path="/searchResult" element={<SearchResult />} />
<Route path="/resultSummary" element={<ResultSummary />} />
<Route path="/ThirdPartyAppView" element={<ThirdPartyAppView />} />
<Route path="/releaseSummary" element={<ReleaseSummary />} />
<Route
path="/"
element={<TopLevelBuilds />}
/>
<Route
path="/admin/settings"
element={<Settings />}
/>
<Route
path="/dashboard"
element={<Dashboard />}
/>
<Route
path="/tests/:type"
element={<TopLevelBuilds />}
/>
<Route
path="/output/:outputType"
element={<Output />}
/>
<Route
path="/deepHistory"
element={<DeepHistory />}
/>
<Route
path="/gitNewIssue"
element={<GitNewIssue />}
/>
<Route
path="/testCompare"
element={<TestCompare />}
/>
<Route
path="/perfCompare"
element={<PerfCompare />}
/>
<Route
path="/tabularView"
element={<TabularView />}
/>
<Route
path="/buildDetail"
element={<BuildDetail />}
/>
<Route
path="/buildTreeView"
element={<BuildTreeView />}
/>
<Route
path="/builds"
element={<Builds />}
/>
<Route
path="/allTestsInfo"
element={<AllTestsInfo />}
/>
<Route
path="/testPerPlatform"
element={<TestPerPlatform />}
/>
<Route
path="/possibleIssues"
element={<PossibleIssues />}
/>
<Route
path="/searchResult"
element={<SearchResult />}
/>
<Route
path="/resultSummary"
element={<ResultSummary />}
/>
<Route
path="/ThirdPartyAppView"
element={<ThirdPartyAppView />}
/>
<Route
path="/releaseSummary"
element={<ReleaseSummary />}
/>
<Route
path="/advancedSearch"
element={<AdvancedSearch />}
/>
</Routes>
</Content>
</ErrorBoundary>
Expand Down
Loading
Loading