fix off by 1 pledge sync issue

This commit is contained in:
Barry Gitarts 2019-01-22 14:58:11 -05:00
parent 304082ff21
commit b7b39205d2
2 changed files with 3 additions and 3 deletions

View File

@ -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 () => {

View File

@ -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' },