Skip to content

Commit

Permalink
fix: issuance staging
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Jan 31, 2022
1 parent 262d816 commit 01c5064
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/controllers/units.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export const create = async (req, res) => {
}

if (newRecord.issuance) {
newRecord.labels.id = uuidv4();
newRecord.labels.orgUid = orgUid;
newRecord.issuance.id = uuidv4();
newRecord.issuance.orgUid = orgUid;
}

const stagedData = {
Expand Down
3 changes: 2 additions & 1 deletion src/fullnode/syncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const syncDataLayerStoreToClimateWarehouse = async (storeId) => {
const model = key.split('|')[0];
const value = JSON.parse(new Buffer(kv.value, 'hex').toString());

console.log(model, value);
if (model === 'unit') {
await Unit.upsert(value);
await Staging.destroy({
Expand All @@ -125,7 +126,7 @@ export const syncDataLayerStoreToClimateWarehouse = async (storeId) => {
await LabelUnit.upsert(value);
} else if (model === 'coBenefits') {
await CoBenefit.upsert(value);
} else if (model === 'issuances') {
} else if (model === 'issuances' || model === 'issuance') {
await Issuance.upsert(value);
} else if (model === 'projectLocations') {
await ProjectLocation.upsert(value);
Expand Down
18 changes: 17 additions & 1 deletion src/models/units/units.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { Label, Issuance, Staging } from '../../models';
import { UnitMirror } from './units.model.mirror';
import ModelTypes from './units.modeltypes.cjs';

import util from 'util';
import {
createXlsFromSequelizeResults,
transformFullXslsToChangeList,
Expand Down Expand Up @@ -290,13 +290,29 @@ class Unit extends Model {
const [insertRecords, updateRecords, deleteChangeList] =
Staging.seperateStagingDataIntoActionGroups(stagedData, 'Units');

console.log(
util.inspect(insertRecords, {
showHidden: false,
depth: null,
colors: true,
}),
);

const insertXslsSheets = createXlsFromSequelizeResults(
insertRecords,
Unit,
false,
true,
);

console.log(
util.inspect(insertXslsSheets, {
showHidden: false,
depth: null,
colors: true,
}),
);

const updateXslsSheets = createXlsFromSequelizeResults(
updateRecords,
Unit,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/project.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Project Resource Integration Tests', function () {
homeOrgUid = await testFixtures.getHomeOrgId();
});

it.only('deletes a project end-to-end (with simulator)', async function () {
it('deletes a project end-to-end (with simulator)', async function () {
/*
Basic Idea for this test is that we are going to create a project and verify that
the new project propagates through the data layer and into our db. Then we are going
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Unit Resource Integration Tests', function () {
homeOrgUid = await testFixtures.getHomeOrgId();
});

it('deletes a unit end-to-end (with simulator)', async function () {
it.only('deletes a unit end-to-end (with simulator)', async function () {
/*
Basic Idea for this test is that we are going to create a unit and verify that
the new unit propagates through the data layer and into our db. Then we are going
Expand Down

0 comments on commit 01c5064

Please sign in to comment.