Skip to content

Commit

Permalink
Merge pull request #2137 from gtech-mulearn/dev-server
Browse files Browse the repository at this point in the history
Dev server
  • Loading branch information
jelanmathewjames authored Jul 5, 2024
2 parents 623a340 + ba8c2c8 commit 3967b35
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions api/launchpad/launchpad_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,30 @@ def get(self, request):
task__hashtag='#lp24-introduction',
).values('user')

latest_org_link = UserOrganizationLink.objects.filter(
user=OuterRef('id'),
org__org_type__in=allowed_org_types
).order_by('-created_at').values('org__title')[:1]

latest_district = UserOrganizationLink.objects.filter(
user=OuterRef('id'),
org__org_type__in=allowed_org_types
).order_by('-created_at').values('org__district__name')[:1]

latest_state = UserOrganizationLink.objects.filter(
user=OuterRef('id'),
org__org_type__in=allowed_org_types
).order_by('-created_at').values('org__district__zone__state__name')[:1]

users = User.objects.filter(
karma_activity_log_user__task__event="launchpad",
karma_activity_log_user__appraiser_approved=True,
id__in=intro_task_completed_users
).prefetch_related(
Prefetch(
"user_organization_link_user",
queryset=UserOrganizationLink.objects.filter(org__org_type__in=allowed_org_types),
)
).filter(
Q(user_organization_link_user__user_id__in=UserOrganizationLink.objects.filter(
org__org_type__in=["College", "School", "Company", "Community"]
).values("user_id")) | Q(user_organization_link_user__id__isnull=True)
).annotate(
karma=Subquery(total_karma_subquery, output_field=IntegerField()),
org=F("user_organization_link_user__org__title"),
district_name=F("user_organization_link_user__org__district__name"),
state=F("user_organization_link_user__org__district__zone__state__name"),
org=Subquery(latest_org_link),
district_name=Subquery(latest_district),
state=Subquery(latest_state),
time_=Max("karma_activity_log_user__created_at"),
).order_by("-karma", "time_")

Expand Down

0 comments on commit 3967b35

Please sign in to comment.