150 resovle channels updates #156
4 changed files with 12 additions and 25 deletions
|
@ -42,7 +42,7 @@ module.exports = {
|
||||||
};
|
};
|
||||||
return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, fileRecord, upsertCriteria, 'Claim')]);
|
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');
|
logger.debug('File and Claim records successfully created');
|
||||||
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
|
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
|
||||||
})
|
})
|
||||||
|
|
|
@ -144,10 +144,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
getTrendingClaims (startDate) {
|
getTrendingClaims (startDate) {
|
||||||
logger.debug('retrieving trending requests');
|
logger.debug('retrieving trending requests');
|
||||||
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// get the raw requests data
|
// get the raw requests data
|
||||||
db.getTrendingClaims(dateTime)
|
db.getTrendingClaims(startDate)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
resolve(results);
|
resolve(results);
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
const { postToStats, getTrendingClaims } = require('../controllers/statsController.js');
|
const { postToStats } = require('../controllers/statsController.js');
|
||||||
const errorHandlers = require('../helpers/errorHandlers.js');
|
|
||||||
|
|
||||||
module.exports = app => {
|
module.exports = app => {
|
||||||
// route for the home page
|
// route for the home page
|
||||||
app.get('/', ({ headers, ip, originalUrl }, res) => {
|
app.get('/', (req, res) => {
|
||||||
// get yesterday's date
|
res.status(200).render('index');
|
||||||
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
// a catch-all route if someone visits a page that does not exist
|
// 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
|
// post to stats
|
||||||
postToStats('show', originalUrl, ip, null, null, 'Error: 404');
|
postToStats('show', originalUrl, ip, null, null, 'Error: 404');
|
||||||
// send response
|
// send response
|
||||||
|
|
|
@ -4,15 +4,16 @@ const { postToStats, getStatsSummary, getTrendingClaims, getRecentClaims } = req
|
||||||
|
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
// route to show 'about' page for spee.ch
|
// route to show 'about' page for spee.ch
|
||||||
app.get('/about', ({ ip, originalUrl }, res) => {
|
app.get('/about', (req, res) => {
|
||||||
// get and render the content
|
// get and render the content
|
||||||
res.status(200).render('about');
|
res.status(200).render('about');
|
||||||
});
|
});
|
||||||
// route to display a list of the trending images
|
// route to display a list of the trending images
|
||||||
app.get('/popular', ({ params, headers }, res) => {
|
app.get('/popular', (req, res) => {
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
startDate.setDate(startDate.getDate() - 1);
|
||||||
getTrendingClaims(startDate)
|
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
getTrendingClaims(dateTime)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// logger.debug(result);
|
// logger.debug(result);
|
||||||
res.status(200).render('trending', { trendingAssets: result });
|
res.status(200).render('trending', { trendingAssets: result });
|
||||||
|
@ -22,10 +23,8 @@ module.exports = (app) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// route to display a list of the trending images
|
// route to display a list of the trending images
|
||||||
app.get('/new', ({ params, headers }, res) => {
|
app.get('/new', (req, res) => {
|
||||||
const startDate = new Date();
|
getRecentClaims()
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
|
||||||
getRecentClaims(startDate)
|
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// logger.debug(result);
|
// logger.debug(result);
|
||||||
res.status(200).render('new', { newClaims: result });
|
res.status(200).render('new', { newClaims: result });
|
||||||
|
|
Loading…
Add table
Reference in a new issue