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

fix: xls import was emptying the datasheet before import #595

Merged
merged 1 commit into from
Jun 7, 2022
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 src/controllers/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const updateFromXLS = async (req, res) => {

const xlsxParsed = xlsx.parse(files.xlsx.data);
const stagedDataItems = tableDataFromXlsx(xlsxParsed, Project);

await updateTableWithData(
collapseTablesData(stagedDataItems, Project),
Project,
Expand Down
136 changes: 68 additions & 68 deletions src/utils/data-loaders.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
import _ from 'lodash';

import request from 'request-promise';

import { Governance } from '../models';
import PickListStub from '../models/governance/governance.stub.json';
import { getConfig } from '../utils/config-loader';
import { logger } from '../config/logger.cjs';

const { USE_SIMULATOR, CHIA_NETWORK } = getConfig().APP;
const { TESTNET_DEFAULT_ORGANIZATIONS } = getConfig().TESTNET;

let downloadedPickList = {};
export const getPicklistValues = () => downloadedPickList;

export const pullPickListValues = async () => {
if (USE_SIMULATOR) {
downloadedPickList = PickListStub;
} else {
const goveranceData = await Governance.findOne({
where: { metaKey: 'pickList' },
raw: true,
});

if (_.get(goveranceData, 'metaValue')) {
downloadedPickList = JSON.parse(goveranceData.metaValue);
}
}

return downloadedPickList;
};

export const getDefaultOrganizationList = async () => {
if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') {
const options = {
method: 'GET',
url: TESTNET_DEFAULT_ORGANIZATIONS,
};

return JSON.parse(await request(Object.assign({}, options)));
} else {
const goveranceData = await Governance.findOne({
where: { metaKey: 'orgList' },
raw: true,
});

return JSON.parse(_.get(goveranceData, 'metaValue', '[]'));
}
};

export const serverAvailable = async (server, port) => {
const options = {
method: 'GET',
url: `http://${server}:${port}`,
};

try {
await request(Object.assign({}, options));
return true;
} catch (err) {
if (JSON.stringify(err).includes('Python')) {
logger.info(`SERVER IS AVAILABLE ${server}`);
return true;
} else {
return false;
}
}
};
import _ from 'lodash';
import request from 'request-promise';
import { Governance } from '../models';
import PickListStub from '../models/governance/governance.stub.json';
import { getConfig } from '../utils/config-loader';
import { logger } from '../config/logger.cjs';
const { USE_SIMULATOR, CHIA_NETWORK } = getConfig().APP;
const { TESTNET_DEFAULT_ORGANIZATIONS } = getConfig().TESTNET;
let downloadedPickList = {};
export const getPicklistValues = () => downloadedPickList;
export const pullPickListValues = async () => {
if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') {
downloadedPickList = PickListStub;
} else {
const goveranceData = await Governance.findOne({
where: { metaKey: 'pickList' },
raw: true,
});
if (_.get(goveranceData, 'metaValue')) {
downloadedPickList = JSON.parse(goveranceData.metaValue);
}
}
return downloadedPickList;
};
export const getDefaultOrganizationList = async () => {
if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') {
const options = {
method: 'GET',
url: TESTNET_DEFAULT_ORGANIZATIONS,
};
return JSON.parse(await request(Object.assign({}, options)));
} else {
const goveranceData = await Governance.findOne({
where: { metaKey: 'orgList' },
raw: true,
});
return JSON.parse(_.get(goveranceData, 'metaValue', '[]'));
}
};
export const serverAvailable = async (server, port) => {
const options = {
method: 'GET',
url: `http://${server}:${port}`,
};
try {
await request(Object.assign({}, options));
return true;
} catch (err) {
if (JSON.stringify(err).includes('Python')) {
logger.info(`SERVER IS AVAILABLE ${server}`);
return true;
} else {
return false;
}
}
};
Loading