Browse Source

Merge branch 'develop' of git.digitaltelepresence.com:digital-telepresence/dtp-base into develop

develop
Rob Colbert 2 years ago
parent
commit
267fb5dbe1
  1. 4
      app/controllers/home.js
  2. 22
      app/services/hive.js

4
app/controllers/home.js

@ -65,12 +65,16 @@ class HomeController extends SiteController {
async getHome (req, res, next) {
const {
announcement: announcementService,
hive: hiveService,
oauth2: oauth2Service,
} = this.dtp.services;
try {
res.locals.announcements = await announcementService.getLatest(req.user);
res.locals.featuredDestinations = await oauth2Service.getRandomClients(3);
res.locals.pagination = this.getPaginationParameters(req, 20);
res.locals.constellationTimeline = await hiveService.getConstellationTimeline(req.user, res.locals.pagination);
res.render('index');
} catch (error) {
this.log.error('failed to render home view', { error });

22
app/services/hive.js

@ -251,6 +251,28 @@ class HiveService extends SiteService {
return event.toObject();
}
async getConstellationTimeline (user, pagination) {
const totalEventCount = await KaleidoscopeEvent.estimatedDocumentCount();
const job = { };
if (user) {
job.search = {
$or: [
{ recipient: { $exists: false } },
{ recipient: user._id },
],
};
} else {
job.search = { recipient: { $exists: false } };
}
const events = await KaleidoscopeEvent
.find(job.search)
.sort({ created: -1 })
.skip(pagination.skip)
.limit(pagination.cpp)
.lean();
return { events, totalEventCount };
}
}
module.exports = {

Loading…
Cancel
Save