Merge pull request #638 from lbryio/controlling-claims-only

filter claims by bid_state: 'Controlling'
This commit is contained in:
Shawn K 2018-10-22 17:15:44 -05:00 committed by GitHub
commit 1bebde8137
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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}`); logger.debug(`claim.getAllChannelClaims for ${channelClaimId}`);
const selectWhere = {publisher_id: channelClaimId};
if (bidState) {
selectWhere.bid_state = bidState;
}
return await table.findAll({ return await table.findAll({
where: { publisher_id: channelClaimId }, where: selectWhere,
order: [['height', 'DESC']], order: [['height', 'DESC']],
}) })
.then(channelClaimsArray => { .then(channelClaimsArray => {
if(channelClaimsArray.length === 0) { if (channelClaimsArray.length === 0) {
return null; return null;
} }
return channelClaimsArray;
return channelClaimsArray; });
})
}, },
getClaimIdByLongChannelId: async (channelClaimId, claimName) => { getClaimIdByLongChannelId: async (channelClaimId, claimName) => {