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) {
|
||||
logger.debug('retrieving trending requests');
|
||||
logger.debug('retrieving trending');
|
||||
return new Promise((resolve, reject) => {
|
||||
// get the raw requests data
|
||||
db.getTrendingClaims(startDate)
|
||||
.then(results => {
|
||||
if (results) {
|
||||
results.forEach(element => {
|
||||
const fileExtenstion = element.fileType.substring(element.fileType.lastIndexOf('/') + 1);
|
||||
element['showUrlLong'] = `/${element.claimId}/${element.name}`;
|
||||
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';
|
||||
db.getTrendingFiles(startDate)
|
||||
.then(fileArray => {
|
||||
let claimsPromiseArray = [];
|
||||
if (fileArray) {
|
||||
fileArray.forEach(file => {
|
||||
claimsPromiseArray.push(db.Claim.resolveClaim(file.name, file.claimId));
|
||||
});
|
||||
return Promise.all(claimsPromiseArray);
|
||||
}
|
||||
resolve(results);
|
||||
})
|
||||
.then(claimsArray => {
|
||||
resolve(claimsArray);
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('sequelize error >>', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -73,8 +73,8 @@ db.upsert = (Model, values, condition, tableName) => {
|
|||
});
|
||||
};
|
||||
|
||||
// add a 'getTrendingClaims' method to the db object
|
||||
db.getTrendingClaims = (startDate) => {
|
||||
// add a 'getTrendingFiles' method to the db object. note: change this to get claims directly. might need new association between Request and Claim
|
||||
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 });
|
||||
};
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ module.exports = (app) => {
|
|||
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
||||
getTrendingClaims(dateTime)
|
||||
.then(result => {
|
||||
// logger.debug(result);
|
||||
res.status(200).render('popular', {
|
||||
trendingAssets: result,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue