~andrewsomething/dat-overview/graphs-first-cut

« back to all changes in this revision

Viewing changes to overview/uploads/views.py

  • Committer: Daniel Holbach
  • Date: 2013-06-20 05:20:29 UTC
  • mfrom: (28.1.6 dashboard)
  • Revision ID: daniel.holbach@canonical.com-20130620052029-ui2gq7k91mrnivsm
mergedĀ lp:~andrewsomething/dat-overview/dashboard

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
            color = "gt20"
31
31
        if p.total_uploads >= 50:
32
32
            color = "gt50"
33
 
        ul_info = {'name': p.name, 'lpid': p.lpid,
34
 
                   'total_uploads': p.total_uploads,
35
 
                   'package': p.first_upload.package,
36
 
                   'release': p.first_upload.release,
37
 
                   'first_seen': p.first_upload.timestamp.date(),
38
 
                   'is_active': p.is_active,
39
 
                   'last_seen': p.last_upload.timestamp.date(),
 
33
        ul_info = {'p': p,
40
34
                   'color': color}
41
35
        output.append(ul_info)
42
36
    return render(request, 'first_timers.html', {'output': output})
190
184
    first_timers = []
191
185
    experienced = []
192
186
    inactive = []
 
187
    three_months = timezone.now() - timedelta(days=3 * 30)
193
188
    two_months = timezone.now() - timedelta(days=2 * 30)
194
189
    six_months = timezone.now() - timedelta(days=6 * 30)
195
190
    one_year = timezone.now() - timedelta(days=365)
196
 
    for p in People.objects.all().order_by('last_upload__timestamp'):
197
 
        if (len(first_timers) < 5 and p.first_upload.timestamp > two_months
 
191
    for p in People.objects.all().order_by('last_upload__timestamp').reverse():
 
192
        if (len(first_timers) < 20 and p.first_upload.timestamp > three_months
198
193
                                 and p.contacted is False):
199
194
            first_timers.append(p)
200
 
        if (len(experienced) < 5 and p.first_upload.timestamp < six_months
 
195
        if (len(experienced) < 20 and p.first_upload.timestamp < six_months
201
196
             and p.ubuntu_dev is not True
202
197
             and p.total_uploads >= 40
203
198
             and p.is_active is True
204
199
             and p.contacted is False):
205
200
               experienced.append(p)
206
 
        if len(inactive) < 5:
 
201
        if len(inactive) < 20:
207
202
            ul_date = p.last_upload.timestamp
208
 
            if (ul_date > one_year and ul_date < two_months and p.contacted is False):
209
 
                inactive.append(p)
 
203
            if (ul_date > one_year and ul_date < two_months 
 
204
                and p.contacted is False and p.total_uploads >= 5):
 
205
                  inactive.append(p)
210
206
    return {'first_timers': first_timers,
211
207
            'experienced': experienced,
212
208
            'inactive': inactive}