Browse Source

link visit logging

pull/1/head
Rob Colbert 3 years ago
parent
commit
ba93049c4d
  1. 5
      app/controllers/link.js

5
app/controllers/link.js

@ -68,6 +68,8 @@ class LinkController extends SiteController {
async postCreateLinkVisit (req, res, next) {
const { link: linkService, resource: resourceService } = this.dtp.services;
try {
this.log.info('recording link visit', { link: res.locals.link._id, ip: req.ip });
/*
* Do these jobs in parallel so the total work gets done faster
*/
@ -75,7 +77,8 @@ class LinkController extends SiteController {
linkService.recordVisit(res.locals.link, req),
resourceService.recordView(req, 'Link', res.locals.link._id),
];
await Promise.all(jobs); // we don't care about any specific results
await Promise.all(jobs);
res.redirect(res.locals.link.href); // off you go!
} catch (error) {

Loading…
Cancel
Save