Browse Source

minor stats bugfix

master
Christian Müller 10 years ago
parent
commit
d57ed022dc
  1. 7
      server.js

7
server.js

@ -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);
}); });
}); });

Loading…
Cancel
Save