def test_interest_compensation_report_queryset(self): """Get a list of `Interest`s sorted by their bankroll of `Lobbyist`s.""" YEAR = 2000 for i in range(10): LobbyistFactory.create() InterestFactory.create() InterestFactory.create() for i in Interest.objects.all(): lobbyist = Lobbyist.objects.all().order_by('?')[0] try: annum = LobbyistAnnum.objects.get(lobbyist=lobbyist, year=YEAR) except LobbyistAnnum.DoesNotExist: annum = LobbyistAnnumFactory.create(lobbyist=lobbyist, year=YEAR) CompensationFactory(annum=annum, interest=i) # denormalize interest stats i.make_stats_for_year(YEAR) # use `__exact`, django ORM attempts to evaluate __year as a date lookup for stat in InterestStats.objects.filter( year__exact=YEAR).order_by('-guess'): # print stat stat
def test_interest_compensation_report_queryset(self): """Get a list of `Interest`s sorted by their bankroll of `Lobbyist`s.""" YEAR = 2000 for i in range(10): LobbyistFactory.create() InterestFactory.create() InterestFactory.create() for i in Interest.objects.all(): lobbyist = Lobbyist.objects.all().order_by('?')[0] try: annum = LobbyistAnnum.objects.get(lobbyist=lobbyist, year=YEAR) except LobbyistAnnum.DoesNotExist: annum = LobbyistAnnumFactory.create(lobbyist=lobbyist, year=YEAR) CompensationFactory(annum=annum, interest=i) # denormalize interest stats i.make_stats_for_year(YEAR) # use `__exact`, django ORM attempts to evaluate __year as a date lookup for stat in InterestStats.objects.filter(year__exact=YEAR).order_by( '-guess'): # print stat stat