popular topics will use topic creation time

This commit is contained in:
barisusakli
2015-01-07 13:35:49 -05:00
parent 2d4383c7b0
commit c1ac92ac19
3 changed files with 16 additions and 14 deletions

View File

@@ -3,10 +3,9 @@
'use strict';
var async = require('async'),
winston = require('winston'),
db = require('../database');
module.exports = function(Topics) {
var terms = {
day: 86400000,
@@ -18,7 +17,7 @@ module.exports = function(Topics) {
Topics.getLatestTopics = function(uid, start, end, term, callback) {
async.waterfall([
function (next) {
Topics.getLatestTids(start, end, term, next);
Topics.getLatestTidsFromSet('topics:recent', start, end, term, next);
},
function(tids, next) {
Topics.getTopics(tids, uid, next);
@@ -30,6 +29,11 @@ module.exports = function(Topics) {
};
Topics.getLatestTids = function(start, end, term, callback) {
winston.warn('[deprecation warning] please use Topics.getLatestTidsFromSet("topics:recent")');
Topics.getLatestTidsFromSet('topics:recent', start, end, term, callback);
};
Topics.getLatestTidsFromSet = function(set, start, end, term, callback) {
var since = terms.day;
if (terms[term]) {
since = terms[term];
@@ -37,7 +41,7 @@ module.exports = function(Topics) {
var count = parseInt(end, 10) === -1 ? end : end - start + 1;
db.getSortedSetRevRangeByScore('topics:recent', start, count, '+inf', Date.now() - since, callback);
db.getSortedSetRevRangeByScore(set, start, count, '+inf', Date.now() - since, callback);
};
Topics.updateTimestamp = function(tid, timestamp, callback) {