Skip to content

Commit

Permalink
fix: picklists load on testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed May 26, 2022
1 parent 5f5f8d5 commit 2737349
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 150 deletions.
113 changes: 0 additions & 113 deletions 0001-feat-sort-by-serial-number.patch

This file was deleted.

15 changes: 14 additions & 1 deletion src/models/governance/governance.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { keyValueToChangeList } from '../../utils/datalayer-utils';
import { getConfig } from '../../utils/config-loader';
import { logger } from '../../config/logger.cjs';
import { getDataModelVersion } from '../../utils/helpers';
import PickListStub from './governance.stub.json';

const { GOVERANCE_BODY_ID, GOVERNANCE_BODY_IP, GOVERNANCE_BODY_PORT } =
getConfig().GOVERNANCE;

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

import ModelTypes from './governance.modeltypes.cjs';

Expand Down Expand Up @@ -82,6 +83,12 @@ class Governance extends Model {
metaValue: governanceData.pickList,
confirmed: true,
});
} else if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') {
updates.push({
metaKey: 'pickList',
metaValue: PickListStub,
confirmed: true,
});
}

await Promise.all(updates.map(async (update) => Governance.upsert(update)));
Expand Down Expand Up @@ -118,6 +125,12 @@ class Governance extends Model {
);

await Governance.upsertGovernanceDownload(versionedGovernanceData);
} else if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') {
Governance.upsert({
metaKey: 'pickList',
metaValue: PickListStub,
confirmed: true,
});
} else {
throw new Error(
`Governance data is not available from this source for ${dataModelVersion} data model.`,
Expand Down
2 changes: 0 additions & 2 deletions src/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ToadScheduler } from 'toad-scheduler';

import syncDataLayer from './sync-datalayer';
import syncDefaultOrganizations from './sync-default-organizations';
import syncPickLists from './sync-picklists';
import syncAudit from './sync-audit-table';
import syncOrganizationMeta from './sync-organization-meta';
import syncGovernanceBody from './sync-governance-body';
Expand All @@ -22,7 +21,6 @@ const start = () => {
syncGovernanceBody,
syncDataLayer,
syncDefaultOrganizations,
syncPickLists,
syncAudit,
syncOrganizationMeta,
];
Expand Down
29 changes: 0 additions & 29 deletions src/tasks/sync-picklists.js

This file was deleted.

4 changes: 3 additions & 1 deletion src/utils/data-loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let downloadedPickList = {};
export const getPicklistValues = () => downloadedPickList;

export const pullPickListValues = async () => {
if (USE_SIMULATOR || CHIA_NETWORK === 'testnet') {
if (USE_SIMULATOR) {
downloadedPickList = PickListStub;
} else {
const goveranceData = await Governance.findOne({
Expand All @@ -26,6 +26,8 @@ export const pullPickListValues = async () => {
downloadedPickList = JSON.parse(goveranceData.metaValue);
}
}

return downloadedPickList;
};

export const getDefaultOrganizationList = async () => {
Expand Down
1 change: 0 additions & 1 deletion src/utils/defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"IS_GOVERNANCE_BODY": false
},
"TESTNET": {
"TESTNET_PICKLIST_URL": "https://climate-warehouse.s3.us-west-2.amazonaws.com/public/picklists.json",
"TESTNET_DEFAULT_ORGANIZATIONS": "https://climate-warehouse.s3.us-west-2.amazonaws.com/public/cw-organizations-testnet.json"
},
"GOVERNANCE": {
Expand Down
8 changes: 5 additions & 3 deletions tests/resources/organization.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ describe('Orgainzation Resource CRUD', function () {
// add a project to the staging table
await testFixtures.createNewProject();

const response = await supertest(app).put(`/v1/organizations/resync`).send({
orgUid: '1',
});
const response = await supertest(app)
.put(`/v1/organizations/resync`)
.send({
orgUid: '1',
});

expect(response.body.message).to.equal(
'Resyncing organization completed',
Expand Down

0 comments on commit 2737349

Please sign in to comment.