2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2018-03-28 19:01:23 +08:00
|
|
|
module.exports = function incrementMapViewCount (metadataBackend) {
|
2019-10-22 01:07:24 +08:00
|
|
|
return function incrementMapViewCountMiddleware (req, res, next) {
|
2018-03-28 19:01:23 +08:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|