Merge pull request #668 from lbryio/bid-state-filter

update bid_state filter
This commit is contained in:
Travis Eden 2018-10-30 14:42:55 -04:00 committed by GitHub
commit a4b02b9f4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,12 +63,19 @@ export default (db, table, sequelize) => ({
});
},
getAllChannelClaims: async (channelClaimId, bidState = 'Controlling') => {
getAllChannelClaims: async (channelClaimId, bidState) => {
logger.debug(`claim.getAllChannelClaims for ${channelClaimId}`);
const selectWhere = {publisher_id: channelClaimId};
if (bidState) {
selectWhere.bid_state = bidState;
}
const whereClause = bidState || {
[sequelize.Op.or]: [
{ bid_state: 'Controlling' },
{ bid_state: 'Active' },
{ bid_state: 'Accepted' },
],
};
const selectWhere = {
...whereClause,
publisher_id: channelClaimId,
};
return await table.findAll({
where: selectWhere,
order: [['height', 'DESC']],