change hash_date only record the new inserted torrents

This commit is contained in:
Kevin Lynx 2013-07-19 21:08:32 +08:00
parent 76542be37a
commit 37ccb19575

View File

@ -34,7 +34,8 @@ ensure_date_index(Conn) ->
insert(Conn, Hash, ReqCnt) when is_list(Hash) -> insert(Conn, Hash, ReqCnt) when is_list(Hash) ->
DaySecs = time_util:now_day_seconds(), DaySecs = time_util:now_day_seconds(),
BHash = list_to_binary(Hash), BHash = list_to_binary(Hash),
Cmd = {findAndModify, ?COLLNAME, query, {'_id', BHash}, upsert, true, % only record today new inserted torrent
Cmd = {findAndModify, ?COLLNAME, query, {'_id', BHash}, % upsert, true,
update, {'$inc', {reqs, ReqCnt}, '$set', {?DATE_COL, DaySecs}}, fields, {'_id', 1}}, update, {'$inc', {reqs, ReqCnt}, '$set', {?DATE_COL, DaySecs}}, fields, {'_id', 1}},
IRet = mongo:do(safe, master, Conn, ?DBNAME, fun() -> IRet = mongo:do(safe, master, Conn, ?DBNAME, fun() ->
mongo:command(Cmd) mongo:command(Cmd)