From 3eae4414ab9e01e152f7243b84a215b43fec11a2 Mon Sep 17 00:00:00 2001 From: Travis Eden Date: Fri, 19 Oct 2018 11:36:42 -0400 Subject: [PATCH] add bidState parameter option --- server/chainquery/queries/claimQueries.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/chainquery/queries/claimQueries.js b/server/chainquery/queries/claimQueries.js index a8d42ca1..563f7246 100644 --- a/server/chainquery/queries/claimQueries.js +++ b/server/chainquery/queries/claimQueries.js @@ -63,19 +63,22 @@ export default (db, table, sequelize) => ({ }); }, - getAllChannelClaims: async (channelClaimId) => { + getAllChannelClaims: async (channelClaimId, bidState = 'Controlling') => { logger.debug(`claim.getAllChannelClaims for ${channelClaimId}`); + const selectWhere = {publisher_id: channelClaimId}; + if (bidState) { + selectWhere.bid_state = bidState; + } return await table.findAll({ - where: { publisher_id: channelClaimId, bid_state: 'Controlling' }, + where: selectWhere, order: [['height', 'DESC']], }) - .then(channelClaimsArray => { - if(channelClaimsArray.length === 0) { - return null; - } - - return channelClaimsArray; - }) + .then(channelClaimsArray => { + if (channelClaimsArray.length === 0) { + return null; + } + return channelClaimsArray; + }); }, getClaimIdByLongChannelId: async (channelClaimId, claimName) => {