From aa7f6d567ceabf3e0e66055edebd9480e2600250 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 12:10:41 -0700 Subject: [PATCH] refactored /popular to use same content list --- controllers/serveController.js | 1 - controllers/statsController.js | 10 ++++++++++ routes/serve-routes.js | 1 - views/partials/trendingAssets.handlebars | 25 ------------------------ views/trending.handlebars | 9 ++++++++- 5 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 views/partials/trendingAssets.handlebars diff --git a/controllers/serveController.js b/controllers/serveController.js index 3c1ff340..89561251 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -155,7 +155,6 @@ module.exports = { allChannelClaims.forEach(element => { const fileExtenstion = element.contentType.substring(element.contentType.lastIndexOf('/') + 1); element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`; - element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`; element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; }); diff --git a/controllers/statsController.js b/controllers/statsController.js index cd103781..413bf0ff 100644 --- a/controllers/statsController.js +++ b/controllers/statsController.js @@ -148,6 +148,16 @@ module.exports = { // 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'] = ''; + }); + } resolve(results); }) .catch(error => { diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 272e47a2..b7574e4b 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -132,7 +132,6 @@ module.exports = (app) => { channelName, channelContents, }; - logger.debug(handlebarsData); res.status(200).render('channel', handlebarsData); } }) diff --git a/views/partials/trendingAssets.handlebars b/views/partials/trendingAssets.handlebars deleted file mode 100644 index c12192fb..00000000 --- a/views/partials/trendingAssets.handlebars +++ /dev/null @@ -1,25 +0,0 @@ -
-

Trending

-

The 25 most popular assets on spee.ch

-
- {{#each trendingAssets}} -
- - {{#ifConditional this.fileType '===' 'video/mp4'}} - - {{else}} - - {{/ifConditional}} - -
-
    -
  • {{this.name}}
  • -
  • Claim Id: {{this.claimId}}
  • -
  • {{this.title}}
  • -
-
-
- {{/each}} -
-
- diff --git a/views/trending.handlebars b/views/trending.handlebars index cc9b963d..65032d6d 100644 --- a/views/trending.handlebars +++ b/views/trending.handlebars @@ -1,4 +1,11 @@
{{> topBar}} - {{> trendingAssets}} +
+

Popular

+

Below are the 25 most popular items on spee.ch

+ {{#each trendingAssets}} + {{> contentListItem}} + {{/each}} +
+ {{> footer}}