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) {
|
2020-06-02 15:00:45 +08:00
|
|
|
const { mapConfig, user, logger } = res.locals;
|
2020-05-26 19:15:35 +08:00
|
|
|
const statTag = mapConfig.obj().stat_tag;
|
|
|
|
|
|
|
|
metadataBackend.incMapviewCount(user, statTag, (err) => {
|
2018-03-28 19:01:23 +08:00
|
|
|
if (err) {
|
2020-07-21 22:36:23 +08:00
|
|
|
logger.warn({ error: err }, 'Failed to increment mapview count');
|
2018-03-28 19:01:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|