150 resovle channels updates #156

Merged
bones7242 merged 11 commits from 150-resovle-channels-updates into master 2017-09-11 00:27:25 +02:00
4 changed files with 12 additions and 25 deletions
Showing only changes of commit a58ca6a167 - Show all commits

View file

@ -42,7 +42,7 @@ module.exports = {
};
return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, fileRecord, upsertCriteria, 'Claim')]);
})
.then((fileRecordResults, claimRecordResults) => {
.then(() => {
logger.debug('File and Claim records successfully created');
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
})

View file

@ -144,10 +144,9 @@ module.exports = {
},
getTrendingClaims (startDate) {
logger.debug('retrieving trending requests');
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
return new Promise((resolve, reject) => {
// get the raw requests data
db.getTrendingClaims(dateTime)
db.getTrendingClaims(startDate)
.then(results => {
resolve(results);
})

View file

@ -1,23 +1,12 @@
const { postToStats, getTrendingClaims } = require('../controllers/statsController.js');
const errorHandlers = require('../helpers/errorHandlers.js');
const { postToStats } = require('../controllers/statsController.js');
module.exports = app => {
// route for the home page
app.get('/', ({ headers, ip, originalUrl }, res) => {
// get yesterday's date
const startDate = new Date();
startDate.setDate(startDate.getDate() - 3);
// send response
getTrendingClaims(startDate)
.then(result => {
res.status(200).render('index', { trendingAssets: result });
})
.catch(error => {
errorHandlers.handleRequestError(error, res);
});
app.get('/', (req, res) => {
res.status(200).render('index');
});
// a catch-all route if someone visits a page that does not exist
app.use('*', ({ headers, originalUrl, ip }, res) => {
app.use('*', ({ originalUrl, ip }, res) => {
// post to stats
postToStats('show', originalUrl, ip, null, null, 'Error: 404');
// send response

View file

@ -4,15 +4,16 @@ const { postToStats, getStatsSummary, getTrendingClaims, getRecentClaims } = req
module.exports = (app) => {
// route to show 'about' page for spee.ch
app.get('/about', ({ ip, originalUrl }, res) => {
app.get('/about', (req, res) => {
// get and render the content
res.status(200).render('about');
});
// route to display a list of the trending images
app.get('/popular', ({ params, headers }, res) => {
app.get('/popular', (req, res) => {
const startDate = new Date();
startDate.setDate(startDate.getDate() - 1);
getTrendingClaims(startDate)
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
getTrendingClaims(dateTime)
.then(result => {
// logger.debug(result);
res.status(200).render('trending', { trendingAssets: result });
@ -22,10 +23,8 @@ module.exports = (app) => {
});
});
// route to display a list of the trending images
app.get('/new', ({ params, headers }, res) => {
const startDate = new Date();
startDate.setDate(startDate.getDate() - 1);
getRecentClaims(startDate)
app.get('/new', (req, res) => {
getRecentClaims()
.then(result => {
// logger.debug(result);
res.status(200).render('new', { newClaims: result });