Skip to content

Commit

Permalink
Merge branch 'advana-release/v1.32' into 'main'
Browse files Browse the repository at this point in the history
Merge release 1.32 into main

See merge request advana/gamechanger/gamechanger-web-source!961
  • Loading branch information
David Rospond committed Feb 21, 2023
2 parents f5d01f2 + 5c9c04d commit be0c46d
Show file tree
Hide file tree
Showing 36 changed files with 14,850 additions and 14,180 deletions.
10 changes: 9 additions & 1 deletion .gitlab/merge_request_templates/default_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!--- Describe details on testing the ticket - endpoints to call, cURL requests, data objects, frontend pages, etc. -->
<!--- If there are multiple test cases, please list the expected input and output for each. -->

## Checklist:
## Requester Checklist:
<!--- Not all of these are required, but it servers as a reminder for the pull requester and helps the reviewer know what is covered-->

- [ ] Documentation updated
Expand All @@ -31,3 +31,11 @@
- [ ] Clones involved and accounted for
- [ ] RDS migrations or other data manipulation necessary
- [ ] Dev tools or other infrastructure changed

## Reviewer Checklist:
<!--- Not all of these may be required/applicable -->

- [ ] Review the Changelog/Code
- [ ] Test locally and aggressively
- [ ] Message original code author to gain context
- [ ] List connected components that this code may affect below or in a comment
8 changes: 5 additions & 3 deletions backend/node_app/controllers/adminController.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ class AdminController {
}
// remove pdf, and get exported docs
for (let obj of export_history) {
const sel_docs = obj.download_request_body.selectedDocuments;
for (let doc of sel_docs) {
exportDocList.push(doc.split('.pdf')[0]);
if (obj.download_request_body.cloneName === 'gamechanger') {
const sel_docs = obj.download_request_body.selectedDocuments;
for (let doc of sel_docs) {
exportDocList.push(doc.split('.pdf')[0]);
}
}
}
for (let obj of pdf_opened) {
Expand Down
19 changes: 0 additions & 19 deletions backend/node_app/controllers/modularGameChangerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class ModularGameChangerController {
this.graphQuery = this.graphQuery.bind(this);
this.callGraphFunction = this.callGraphFunction.bind(this);
this.callDataFunction = this.callDataFunction.bind(this);
this.upload = this.upload.bind(this);
this.exportReview = this.exportReview.bind(this);
this.exportChecklist = this.exportChecklist.bind(this);
this.exportUsers = this.exportUsers.bind(this);
Expand Down Expand Up @@ -348,24 +347,6 @@ class ModularGameChangerController {
// TODO add Doc Fetcher Handlers
res.status(200).send('TODO');
}
async upload(req, res) {
// upload function
const userId = req.session?.user?.id || req.get('SSL_CLIENT_S_DN_CN');
const cloneName = req.body.cloneName;
const functionName = req.body.functionName;
const options = JSON.parse(req.body.options);
options.file = req.file;

try {
const handler = this.handler_factory.createHandler('data', cloneName);
const results = await handler.callFunction(functionName, options, cloneName, req.permissions, userId);

res.status(200).send(results);
} catch (error) {
res.status(500).send(error, 'N1AF564', userId);
this.logger.error(error, 'N1AF564', userId);
}
}
}

module.exports.ModularGameChangerController = ModularGameChangerController;
12 changes: 9 additions & 3 deletions backend/node_app/lib/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class Reports {
};

const printer = new this.pdfMake(fonts);
const docDefinition = await this.constructProfilePagePDF(data);
const docDefinition = await this.constructProfilePagePDF(data, userId);
const doc = printer.createPdfKitDocument(docDefinition);

let chunks = [];
Expand Down Expand Up @@ -778,7 +778,13 @@ class Reports {
// RDOC Content
const rdocContent = [];

for (const docData of fullData) {
// We need to filter out duplicated reviews that came as
// a result of data propagation from 2022-2023
const docIds = fullData.map((docData) => String(docData.id));
const filteredFullData = fullData.filter(
(docData, index) => !docIds.includes(String(docData.id), index + 1)
);
for (const docData of filteredFullData) {
switch (docData.budgetType) {
case 'pdoc':
procToc[1].table.body.push(
Expand Down Expand Up @@ -945,7 +951,7 @@ class Reports {

areas3.forEach((area3) => {
areas2.forEach((area2) => {
if (JCAData[docData.pocJointCapabilityArea][area2].includes(area3)) {
if (JCAData[docData.pocJointCapabilityArea][area2]?.includes(area3)) {
areasCombined[area2].push(area3);
}
});
Expand Down
188 changes: 181 additions & 7 deletions backend/node_app/modules/eda/edaSearchHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class EdaSearchHandler extends SearchHandler {
let esClientName = 'eda';

// don't get hierarchal naics/psc/dodaac data for now
const query = {
const filter_options_query = {
size: 12,
query: {
bool: {
Expand Down Expand Up @@ -406,19 +406,191 @@ class EdaSearchHandler extends SearchHandler {
},
};

const results = await this.dataLibrary.queryElasticSearch(esClientName, esIndex, query, userId);
const psc_hierarchical_filters_query = {
query: {
bool: {
must: [
{
match: {
picklist_name_s: 'psc',
},
},
],
must_not: [
{
exists: {
field: 'parentCode_s',
},
},
],
},
},
sort: [
{
code_s: {
order: 'asc',
},
},
],
size: 100,
};

let cleanedResults = {};
const naics_hierarchical_filters_query = {
query: {
bool: {
must: [
{
match: {
picklist_name_s: 'naics',
},
},
],
must_not: [
{
exists: {
field: 'parentCode_s',
},
},
],
},
},
sort: [
{
code_s: {
order: 'asc',
},
},
],
size: 100,
};

const filter_options_promise = this.dataLibrary.queryElasticSearch(
esClientName,
esIndex,
filter_options_query,
userId
);

const psc_hierarchical_filters_promise = this.dataLibrary.queryElasticSearch(
esClientName,
esIndex,
psc_hierarchical_filters_query,
userId
);

results.body.hits.hits.forEach((hit) => {
const naics_hierarchical_filters_promise = this.dataLibrary.queryElasticSearch(
esClientName,
esIndex,
naics_hierarchical_filters_query,
userId
);

const [filter_options_results, psc_hierarchical_results, naics_hierarchical_results] = await Promise.all([
filter_options_promise,
psc_hierarchical_filters_promise,
naics_hierarchical_filters_promise,
]);

let cleanedResults = {
filters: {},
hierarchical_filters: { psc: [], naics: [] },
};

filter_options_results.body.hits.hits.forEach((hit) => {
const { picklist_name_s, picklist_s } = hit._source;
cleanedResults[picklist_name_s] = picklist_s;
cleanedResults.filters[picklist_name_s] = picklist_s;
});

psc_hierarchical_results.body.hits.hits.forEach((hit) => {
cleanedResults.hierarchical_filters.psc.push({
code: hit._source.code_s,
name: hit._source.productName_s,
hasChildren: hit._source.hasChildren_b === 'true',
parent: hit._source.parentCode_s,
});
});

naics_hierarchical_results.body.hits.hits.forEach((hit) => {
cleanedResults.hierarchical_filters.naics.push({
code: hit._source.code_s,
name: hit._source.title_s,
hasChildren: hit._source.hasChildren_b === 'true',
parent: hit._source.parentCode_s,
});
});

return cleanedResults;
} catch (e) {
this.logger.error(e.message, 'BI5E7KT');
return {};
}
}

async getHierarchicalFilterData(req, userId) {
try {
const { body } = req;
const { picklistName = '', parentCode = '' } = body;
let esIndex = this.constants.EDA_ELASTIC_SEARCH_OPTS.filterPicklistIndex;
let esClientName = 'eda';

const filter_options_query = {
size: 100,
sort: [
{
code_s: {
order: 'asc',
},
},
],
query: {
bool: {
must: [
{
match: {
picklist_name_s: picklistName === 'naicsCode' ? 'naics' : picklistName,
},
},
{
match: {
parentCode_s: parentCode,
},
},
],
},
},
};

const filter_options_results = await this.dataLibrary.queryElasticSearch(
esClientName,
esIndex,
filter_options_query,
userId
);

let cleanedResults = [];

filter_options_results.body.hits.hits.forEach((hit) => {
if (picklistName === 'naicsCode') {
cleanedResults.push({
code: hit._source.code_s,
name: hit._source.title_s,
hasChildren: hit._source.hasChildren_b === 'true',
parent: hit._source.parentCode_s,
});
} else if (picklistName === 'psc') {
cleanedResults.push({
code: hit._source.code_s,
name: hit._source.productName_s,
hasChildren: hit._source.hasChildren_b === 'true',
parent: hit._source.parentCode_s,
});
}
});

return cleanedResults;
} catch (e) {
this.logger.error(e.message, 'OICE7JS');
return { orgs: [], types: [] };
this.logger.error(e.message, 'B5YNTJC');
return {};
}
}

Expand All @@ -437,6 +609,8 @@ class EdaSearchHandler extends SearchHandler {
return await this.querySimilarDocs(req, userId);
case 'getPresearchData':
return await this.getPresearchData(req, userId);
case 'getHierarchicalFilterData':
return await this.getHierarchicalFilterData(req, userId);
default:
this.logger.error(
`There is no function called ${functionName} defined in the edaSearchHandler`,
Expand Down
Loading

0 comments on commit be0c46d

Please sign in to comment.