From b7b39205d297c93f8468efef4a84562c6a1ba16d Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Tue, 22 Jan 2019 14:58:11 -0500 Subject: [PATCH] fix off by 1 pledge sync issue --- app/actions/pledges.js | 4 ++-- app/model/schema.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/actions/pledges.js b/app/actions/pledges.js index f4dba15..6aeb91a 100644 --- a/app/actions/pledges.js +++ b/app/actions/pledges.js @@ -6,7 +6,7 @@ import { getProfilesById } from './profiles' const createPledge = (pledge, data, profiles) => { const { id, owner, amount, token, commitTime, nDelegates, pledgeState, intendedProject } = data const profile = profiles.find(p => p.idProfile == owner) - pledge.pledgeId = id + pledge.pledgeId = Number(id) pledge.owner = Number(owner) pledge.amount = amount pledge.token = token @@ -36,7 +36,7 @@ export const batchAddPledges = async (pledges, profiles = []) => { const getLastPledge = pledges => { const pledgeId = pledges.length ? pledges.sort((a,b) => b.pledgeId - a.pledgeId)[0].pledgeId - : 1 + : 0 return pledgeId } export const getAndAddPledges = async () => { diff --git a/app/model/schema.js b/app/model/schema.js index f0015b4..7811ac8 100644 --- a/app/model/schema.js +++ b/app/model/schema.js @@ -29,7 +29,7 @@ export default appSchema({ tableSchema({ name: 'pledges', columns: [ - { name: 'pledge_id', type: 'number' }, + { name: 'pledge_id', type: 'number', isIndexed: true }, { name: 'owner_id', type: 'number', isIndexed: true }, { name: 'amount', type: 'string' }, { name: 'token', type: 'string' },