add bidState parameter option

This commit is contained in:
Travis Eden 2018-10-19 11:36:42 -04:00
parent 7785320f49
commit 3eae4414ab

View file

@ -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;
})
});
},
getClaimIdByLongChannelId: async (channelClaimId, claimName) => {