fixes blank tiles due to unsupported content #755
3 changed files with 62 additions and 16 deletions
|
@ -869,15 +869,35 @@ var claimQueries = (db, table, sequelize) => ({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getAllChannelClaims: async (channelClaimId, bidState) => {
|
getAllChannelClaims: async (channelClaimId, params) => {
|
||||||
logger$1.debug(`claim.getAllChannelClaims for ${channelClaimId}`);
|
logger$1.debug(`claim.getAllChannelClaims for ${channelClaimId}`);
|
||||||
const whereClause = bidState || {
|
|
||||||
[sequelize.Op.or]: [
|
const defaultWhereClauses = {
|
||||||
{ bid_state: 'Controlling' },
|
bid_state:
|
||||||
{ bid_state: 'Active' },
|
{ [sequelize.Op.or]: ['Controlling', 'Active', 'Accepted'] }
|
||||||
{ bid_state: 'Accepted' },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addWhereClauses = (whereClauses, params) => {
|
||||||
|
/*
|
||||||
|
input params = { col: ['Val', 'Val']}
|
||||||
|
output = { col: { Op.or : [ { Op.eq: 'Value'},...]}, col2:...}
|
||||||
|
*/
|
||||||
|
const cols = Object.keys(params);
|
||||||
|
for (let colKey in cols){
|
||||||
|
let col = Object.keys(params)[colKey];
|
||||||
|
|
||||||
|
whereClauses[col] = {};
|
||||||
|
whereClauses[col][sequelize.Op.or] = [];
|
||||||
|
for (let itemKey in params[col] ){
|
||||||
|
let itemsArr = params[col];
|
||||||
|
whereClauses[col][sequelize.Op.or].push({ [sequelize.Op.eq]: itemsArr[itemKey] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return whereClauses;
|
||||||
|
};
|
||||||
|
|
||||||
|
const whereClause = addWhereClauses(defaultWhereClauses, params);
|
||||||
|
|
||||||
const selectWhere = {
|
const selectWhere = {
|
||||||
...whereClause,
|
...whereClause,
|
||||||
publisher_id: channelClaimId,
|
publisher_id: channelClaimId,
|
||||||
|
|
|
@ -68,15 +68,35 @@ export default (db, table, sequelize) => ({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
|
|
||||||
getAllChannelClaims: async (channelClaimId, bidState) => {
|
getAllChannelClaims: async (channelClaimId, params) => {
|
||||||
logger.debug(`claim.getAllChannelClaims for ${channelClaimId}`);
|
logger.debug(`claim.getAllChannelClaims for ${channelClaimId}`);
|
||||||
const whereClause = bidState || {
|
|
||||||
[sequelize.Op.or]: [
|
const defaultWhereClauses = {
|
||||||
See here and the original signature of See here and the original signature of `getAllChannelClaims: async (channelClaimId, bidState)`, this allows all claims to be fetched. The changes break this pattern and force Spee.ch filtering on code that should be unopinionated.
I had read that once you go beyond 1 optional parameter, you're better off passing an object. With bidState already being optional and not passed from the controller, contentTypes would have to be a second optional parameter, meaning the function, I think, would have to be called with ( first, null, third ). Is there a better way to make contentTypes optional? I'm leading toward a GetMatchingChannelClaims function in chainquery instead. This would pave the way for future db queries. I had read that once you go beyond 1 optional parameter, you're better off passing an object. With bidState already being optional and not passed from the controller, contentTypes would have to be a second optional parameter, meaning the function, I think, would have to be called with ( first, null, third ). Is there a better way to make contentTypes optional? I'm leading toward a GetMatchingChannelClaims function in chainquery instead. This would pave the way for future db queries.
|
|||||||
{ bid_state: 'Controlling' },
|
bid_state:
|
||||||
{ bid_state: 'Active' },
|
{ [sequelize.Op.or]: ['Controlling', 'Active', 'Accepted'] }
|
||||||
{ bid_state: 'Accepted' },
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addWhereClauses = (whereClauses, params) => {
|
||||||
|
/*
|
||||||
|
input params = { col: ['Val', 'Val']}
|
||||||
|
output = { col: { Op.or : [ { Op.eq: 'Value'},...]}, col2:...}
|
||||||
|
*/
|
||||||
|
const cols = Object.keys(params)
|
||||||
|
for (let colKey in cols){
|
||||||
|
let col = Object.keys(params)[colKey]
|
||||||
|
|
||||||
|
whereClauses[col] = {}
|
||||||
|
whereClauses[col][sequelize.Op.or] = []
|
||||||
|
for (let itemKey in params[col] ){
|
||||||
|
let itemsArr = params[col]
|
||||||
|
whereClauses[col][sequelize.Op.or].push({ [sequelize.Op.eq]: itemsArr[itemKey] })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return whereClauses;
|
||||||
|
}
|
||||||
|
|
||||||
|
const whereClause = addWhereClauses(defaultWhereClauses, params);
|
||||||
|
|
||||||
const selectWhere = {
|
const selectWhere = {
|
||||||
...whereClause,
|
...whereClause,
|
||||||
publisher_id: channelClaimId,
|
publisher_id: channelClaimId,
|
||||||
|
|
|
@ -5,10 +5,16 @@ const { returnPaginatedChannelClaims } = require('./channelPagination.js');
|
||||||
|
|
||||||
const getChannelClaims = async (channelName, channelShortId, page) => {
|
const getChannelClaims = async (channelName, channelShortId, page) => {
|
||||||
const channelId = await chainquery.claim.queries.getLongClaimId(channelName, channelShortId);
|
const channelId = await chainquery.claim.queries.getLongClaimId(channelName, channelShortId);
|
||||||
|
const params = { content_type: [
|
||||||
|
'image/jpeg',
|
||||||
|
'image/jpg',
|
||||||
|
'image/png',
|
||||||
|
'image/gif',
|
||||||
|
'video/mp4',
|
||||||
|
] };
|
||||||
let channelClaims;
|
let channelClaims;
|
||||||
if (channelId) {
|
if (channelId) {
|
||||||
channelClaims = await chainquery.claim.queries.getAllChannelClaims(channelId);
|
channelClaims = await chainquery.claim.queries.getAllChannelClaims(channelId, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
const processingChannelClaims = channelClaims ? channelClaims.map((claim) => getClaimData(claim)) : [];
|
const processingChannelClaims = channelClaims ? channelClaims.map((claim) => getClaimData(claim)) : [];
|
||||||
|
|
Loading…
Reference in a new issue
This needs to be optional, chainquery functions should not be opinionated on Spee.ch content types.