fixes blank tiles due to unsupported content

This commit is contained in:
Jessop Breth 2018-11-25 23:54:23 -05:00
parent b7d70bb19f
commit 2227ede6e9
3 changed files with 62 additions and 16 deletions

View file

@ -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,

View file

@ -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 = {
{ 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,

View file

@ -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)) : [];