ad58b661aaee955bf8dc8086d805d56485f8c53a,sounds/views.py,,sounds,#Any#,108

Before Change


    latest_sounds = Sound.objects.latest_additions(num_sounds=5, period_days=2)
    latest_packs = Pack.objects.select_related().filter(num_sounds__gt=0).exclude(is_deleted=True).order_by("-last_updated")[0:20]
    last_week = get_n_weeks_back_datetime(n_weeks=1)
    popular_sound_ids = [snd.id for snd in Sound.objects.filter(
            Q(moderation_date__gte=last_week) | Q(created__gte=last_week)).order_by("-num_downloads")[0:5]]
    popular_sounds = Sound.objects.ordered_ids(popular_sound_ids)
    popular_packs = Pack.objects.filter(created__gte=last_week).exclude(is_deleted=True).order_by("-num_downloads")[0:5]
    random_sound_id = get_sound_of_the_day_id()
    if random_sound_id:

After Change


    latest_sounds = Sound.objects.latest_additions(num_sounds=5, period_days=2)
    latest_packs = Pack.objects.select_related().filter(num_sounds__gt=0).exclude(is_deleted=True).order_by("-last_updated")[0:20]
    last_week = get_n_weeks_back_datetime(n_weeks=1)
    popular_sounds = Sound.public.select_related("license", "user") \
                                 .annotate(greatest_date=Greatest("created", "moderation_date")) \
                                 .filter(greatest_date__gte=last_week).order_by("-num_downloads")[0:5]
    popular_packs = Pack.objects.select_related("user").filter(created__gte=last_week).exclude(is_deleted=True).order_by("-num_downloads")[0:5]
    random_sound_id = get_sound_of_the_day_id()
    if random_sound_id:
        random_sound = Sound.objects.bulk_query_id([random_sound_id])[0]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: MTG/freesound
Commit Name: ad58b661aaee955bf8dc8086d805d56485f8c53a
Time: 2019-07-24
Author: alastair.porter@upf.edu
File Name: sounds/views.py
Class Name:
Method Name: sounds


Project Name: chakki-works/doccano
Commit Name: 366d66d43c92480a911ad35715f4ddd5d7a7bb5b
Time: 2020-11-26
Author: light.tree.1.13@gmail.com
File Name: app/api/views.py
Class Name: DocumentList
Method Name: get_queryset


Project Name: okfn-brasil/serenata-de-amor
Commit Name: a460674c772c2c0685148c8eb94b1743afea71d5
Time: 2017-09-28
Author: cuducos@users.noreply.github.com
File Name: jarbas/dashboard/admin.py
Class Name: ReimbursementModelAdmin
Method Name: get_search_results