Skip to content

Commit

Permalink
fix: download valid xls file with search param
Browse files Browse the repository at this point in the history
  • Loading branch information
frantzarty committed May 16, 2022
1 parent 0b55709 commit 7612eab
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/controllers/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ export const findAll = async (req, res) => {
let { page, limit, search, orgUid, columns, xls } = req.query;
let where = orgUid != null && orgUid !== 'all' ? { orgUid } : undefined;

if (orgUid === 'all') {
// 'ALL' orgUid is just a UI concept but they keep forgetting this and send it
// So delete this value if its sent so nothing breaks
orgUid = undefined;
}

const includes = Project.getAssociatedModels();

if (columns) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

export default {
async up(queryInterface) {
queryInterface.sequelize.query(`INSERT INTO projects_fts SELECT
warehouseProjectId,
orgUid,
currentRegistry,
projectId,
registryOfOrigin,
originProjectId,
program,
projectName,
projectLink,
projectDeveloper,
sector,
coveredByNDC,
projectType,
projectTags,
ndcInformation,
projectStatus,
projectStatusDate,
unitMetric,
methodology,
validationBody,
validationDate,
timeStaged,
description
FROM projects`);
},

down() {
return Promise.resolve();
},
};
5 changes: 5 additions & 0 deletions src/database/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import CreateGoveranceTable from './20220315134151-create-governance-table';
import AddCommentColumnToDataModelTables from './20220428144558-add-comment-column-to-all-datamodels';
import AddSerialNumberFields from './20220504180739-add-serial-number-fields';
import AddDescriptionFieldToProjects from './20220509125335-add-description-field-to-projects';
import RepopulateVirtualTables from './20220515223227-re-populate-virtual-tables';

export const migrations = [
{
Expand Down Expand Up @@ -119,4 +120,8 @@ export const migrations = [
migration: AddDescriptionFieldToProjects,
name: '20220509125335-add-description-field-to-projects',
},
{
migration: RepopulateVirtualTables,
name: '20220515223227-re-populate-virtual-tables',
},
];

0 comments on commit 7612eab

Please sign in to comment.