зеркало из https://github.com/mozilla/galaxy-api.git
Detail and submit now uses redis as datastore
This commit is contained in:
Родитель
79bf240c7f
Коммит
9a47fa9d9d
|
@ -103,13 +103,13 @@ exports.publicGameObj = publicGameObj;
|
|||
function getPublicGameObj(client, id, callback) {
|
||||
// `callback` is called with a single parameter, which is either
|
||||
// the public game object or `null`.
|
||||
getGameById(client, id, function(err, resp) {
|
||||
getGameFromID(client, id, function(err, resp) {
|
||||
if (err || !resp) {
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
callback(publicGameObj(JSON.parse(resp)));
|
||||
callback(null, publicGameObj(resp));
|
||||
} catch(e) {
|
||||
callback(null);
|
||||
}
|
||||
|
|
|
@ -24,21 +24,13 @@ module.exports = function(server) {
|
|||
return;
|
||||
}
|
||||
|
||||
gamelib.getGameIDFromSlug(client, slug, function(err, id) {
|
||||
if (err) {
|
||||
gamelib.getGameFromSlug(client, slug, function(err, game) {
|
||||
if (!game) {
|
||||
res.json(500, {error: 'db_error'});
|
||||
done();
|
||||
return;
|
||||
} else {
|
||||
res.json(game);
|
||||
}
|
||||
|
||||
gamelib.getPublicGameObj(client, id, function(game) {
|
||||
if (!game) {
|
||||
res.json(500, {error: 'db_error'});
|
||||
} else {
|
||||
res.json(game);
|
||||
}
|
||||
done();
|
||||
});
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var db = require('../../db');
|
||||
var utils = require('../../lib/utils');
|
||||
var gamelib = require('../../lib/game');
|
||||
|
||||
|
||||
module.exports = function(server) {
|
||||
|
@ -37,7 +38,7 @@ module.exports = function(server) {
|
|||
isRequired: true
|
||||
}
|
||||
}
|
||||
}, function(req, res) {
|
||||
}, db.redisView(function(client, done, req, res, wrap) {
|
||||
var POST = req.params;
|
||||
slug = utils.slugify(POST.slug || POST.name);
|
||||
var data = {
|
||||
|
@ -66,7 +67,8 @@ module.exports = function(server) {
|
|||
slug: slug,
|
||||
videos: POST.videos
|
||||
};
|
||||
db.flatfile.write('game', slug, data);
|
||||
|
||||
gamelib.newGame(client, data);
|
||||
res.json(data);
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче