Windshaft-cartodb/lib/api/middlewares/increment-map-view-count.js

19 lines
579 B
JavaScript
Raw Normal View History

'use strict';
module.exports = function incrementMapViewCount (metadataBackend) {
2019-10-22 01:07:24 +08:00
return function incrementMapViewCountMiddleware (req, res, next) {
const { mapConfig, user } = res.locals;
// Error won't blow up, just be logged.
metadataBackend.incMapviewCount(user, mapConfig.obj().stat_tag, (err) => {
req.profiler.done('incMapviewCount');
if (err) {
global.logger.log(`ERROR: failed to increment mapview count for user '${user}': ${err.message}`);
}
next();
});
};
};