def getRegistrationReferralCounts(startDate,endDate):
timeFilters = {}<EOL>if startDate:<EOL><INDENT>timeFilters['<STR_LIT>'] = startDate<EOL><DEDENT>if endDate:<EOL><INDENT>timeFilters['<STR_LIT>'] = endDate<EOL><DEDENT>regs = Registration.objects.filter(**timeFilters)<EOL>counter = Counter([x.data.get('<STR_LIT>',None) for x in regs if isinstance(x.data,dict)] + [None for x in regs if not isinstance(x.data,dict)])<EOL>results = [{'<STR_LIT:code>': k or _('<STR_LIT:None>'), '<STR_LIT:count>': v} for k,v in counter.items()]<EOL>return results<EOL>
When a user accesses the class registration page through a
referral URL, the marketing_id gets saved in the extra JSON
data associated with that registration.  This just returns
counts associated with how often given referral terms appear
in a specified time window (i.e. how many people signed up
by clicking through a referral button).