Add num_gildings to keep track of gildings count

This will include all types of gildings (gildings of users, links, comments). It
will primarily be used to figure out the proper gilding trophy level since the
previous method could only include up to 1000 gildings.

A backfill script (num_gildings.py) has been created in scripts/migrate/backfill/.
This commit is contained in:
MelissaCole
2015-05-04 17:27:48 -07:00
parent fe98410cc8
commit 7d91d02bf5
2 changed files with 8 additions and 0 deletions

View File

@@ -35,6 +35,7 @@ from r2.lib.csrf import csrf_exempt
from r2.lib.emailer import _system_email
from r2.lib.errors import MessageError
from r2.lib.filters import _force_unicode, _force_utf8
from r2.lib.hooks import get_hook
from r2.lib.log import log_text
from r2.lib.pages import GoldGiftCodeEmail
from r2.lib.strings import strings
@@ -260,11 +261,16 @@ def send_gift(buyer, recipient, months, days, signed, giftmessage,
thing_fullname, note=None):
admintools.adjust_gold_expiration(recipient, days=days)
# increment num_gildings for all types of gildings not to themselves
if buyer != recipient:
buyer._incr("num_gildings")
if thing_fullname:
thing = Thing._by_fullname(thing_fullname, data=True)
thing._gild(buyer)
else:
thing = None
get_hook('user.gild').call(recipient=recipient, gilder=buyer)
if signed:
sender = buyer.name

View File

@@ -64,6 +64,7 @@ class Account(Thing):
'inbox_count',
'num_payment_methods',
'num_failed_payments',
'num_gildings',
)
_int_prop_suffix = '_karma'
_essentials = ('name', )
@@ -127,6 +128,7 @@ class Account(Thing):
gold = False,
gold_charter = False,
gold_creddits = 0,
num_gildings=0,
cake_expiration=None,
otp_secret=None,
state=0,