Skip to content

Commit

Permalink
fix: xls import was emptying the datasheet before import
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Jun 7, 2022
1 parent 38587cd commit cb0a75f
Show file tree
Hide file tree
Showing 4 changed files with 1,110 additions and 1,103 deletions.
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

0 comments on commit cb0a75f

Please sign in to comment.