minor stats bugfix

This commit is contained in:
Christian Müller
2016-01-06 20:38:29 +01:00
parent f4a8e6d890
commit d57ed022dc
+4 -3
View File
@@ -120,9 +120,9 @@ app.get(/\/([a-z0-9]+)/, function (req, res) {
log(req.ip, "open note", link); log(req.ip, "open note", link);
if (CACHE.has(link)) { if (CACHE.has(link)) {
log(link, "is cached!"); log(link, "is cached!");
var model = MODELS[link]; var note = MODELS[link];
if (!model) return notFound(res); if (!note) return notFound(res);
model.views++; note.views++;
res.send(CACHE.get(link)); res.send(CACHE.get(link));
} else storage.getNote(link).then(note => { } else storage.getNote(link).then(note => {
log(link, "is not cached, resolving..."); log(link, "is not cached, resolving...");
@@ -133,6 +133,7 @@ app.get(/\/([a-z0-9]+)/, function (req, res) {
var content = view.renderNote(note); var content = view.renderNote(note);
CACHE.set(link, content); CACHE.set(link, content);
MODELS[link] = note; MODELS[link] = note;
note.views++;
res.send(content); res.send(content);
}); });
}); });