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')]);
|
||||
})
|
||||
.then((fileRecordResults, claimRecordResults) => {
|
||||
.then(() => {
|
||||
logger.debug('File and Claim records successfully created');
|
||||
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
|
||||
})
|
||||
|
|
|
@ -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);
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 });
|
||||
|
|
Loading…
Add table
Reference in a new issue