fixed popular page to display actual thumbnails
This commit is contained in:
parent
e652126a3f
commit
46f9b3d8e1
3 changed files with 13 additions and 16 deletions
|
@ -70,25 +70,23 @@ module.exports = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getTrendingClaims (startDate) {
|
getTrendingClaims (startDate) {
|
||||||
logger.debug('retrieving trending requests');
|
logger.debug('retrieving trending');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// get the raw requests data
|
// get the raw requests data
|
||||||
db.getTrendingClaims(startDate)
|
db.getTrendingFiles(startDate)
|
||||||
.then(results => {
|
.then(fileArray => {
|
||||||
if (results) {
|
let claimsPromiseArray = [];
|
||||||
results.forEach(element => {
|
if (fileArray) {
|
||||||
const fileExtenstion = element.fileType.substring(element.fileType.lastIndexOf('/') + 1);
|
fileArray.forEach(file => {
|
||||||
element['showUrlLong'] = `/${element.claimId}/${element.name}`;
|
claimsPromiseArray.push(db.Claim.resolveClaim(file.name, file.claimId));
|
||||||
element['directUrlLong'] = `/${element.claimId}/${element.name}.${fileExtenstion}`;
|
|
||||||
element['directUrlShort'] = `/${element.claimId}/${element.name}.${fileExtenstion}`;
|
|
||||||
element['contentType'] = element.fileType;
|
|
||||||
element['thumbnail'] = 'https://spee.ch/assets/img/video_thumb_default.png';
|
|
||||||
});
|
});
|
||||||
|
return Promise.all(claimsPromiseArray);
|
||||||
}
|
}
|
||||||
resolve(results);
|
})
|
||||||
|
.then(claimsArray => {
|
||||||
|
resolve(claimsArray);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('sequelize error >>', error);
|
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,8 +73,8 @@ db.upsert = (Model, values, condition, tableName) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// add a 'getTrendingClaims' method to the db object
|
// add a 'getTrendingFiles' method to the db object. note: change this to get claims directly. might need new association between Request and Claim
|
||||||
db.getTrendingClaims = (startDate) => {
|
db.getTrendingFiles = (startDate) => {
|
||||||
return db.sequelize.query(`SELECT COUNT(*), File.* FROM Request LEFT JOIN File ON Request.FileId = File.id WHERE FileId IS NOT NULL AND nsfw != 1 AND trendingEligible = 1 AND Request.createdAt > "${startDate}" GROUP BY FileId ORDER BY COUNT(*) DESC LIMIT 25;`, { type: db.sequelize.QueryTypes.SELECT });
|
return db.sequelize.query(`SELECT COUNT(*), File.* FROM Request LEFT JOIN File ON Request.FileId = File.id WHERE FileId IS NOT NULL AND nsfw != 1 AND trendingEligible = 1 AND Request.createdAt > "${startDate}" GROUP BY FileId ORDER BY COUNT(*) DESC LIMIT 25;`, { type: db.sequelize.QueryTypes.SELECT });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ module.exports = (app) => {
|
||||||
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
getTrendingClaims(dateTime)
|
getTrendingClaims(dateTime)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// logger.debug(result);
|
|
||||||
res.status(200).render('popular', {
|
res.status(200).render('popular', {
|
||||||
trendingAssets: result,
|
trendingAssets: result,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue