Browse files

CampaignBuilder don't combine campaigns on same link.

  • Loading branch information...
1 parent f61587c commit d8c9db9af89b10bbf471f498a7988b90ab048cd7 @bsimpson63 bsimpson63 committed Feb 25, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 r2/r2/models/builder.py
View
7 r2/r2/models/builder.py
@@ -43,6 +43,7 @@
from r2.models.wiki import WIKI_RECENT_DAYS
+from collections import defaultdict
import time
from admintools import compute_votes, admintools, ip_span
@@ -511,11 +512,13 @@ def thing_lookup(self, tuples):
def wrap_items(self, items):
links = [i.thing for i in items]
wrapped = IDBuilder.wrap_items(self, links)
- by_link = {w._fullname: w for w in wrapped}
+ by_link = defaultdict(list)
+ for w in wrapped:
+ by_link[w._fullname].append(w)
ret = []
for i in items:
- w = by_link[i.thing._fullname]
+ w = by_link[i.thing._fullname].pop()
w.campaign = i.campaign
w.weight = i.weight
ret.append(w)

0 comments on commit d8c9db9

Please sign in to comment.