Commit 3606932d authored by Maxime Emschwiller's avatar Maxime Emschwiller
Browse files

feat(backend): Add feedback type to stats_app files

parent 28b5f636
......@@ -77,6 +77,7 @@ def stats(request):
raw_data = [
{
"date": dc.date.strftime("%Y-%m-%d"),
"type": dc.type,
"university": f"{dc.university.pk} - {dc.university.name}",
"major": dc.major,
"minor": dc.minor,
......@@ -88,6 +89,7 @@ def stats(request):
cols = [
"date",
"type",
"university",
"major",
"minor",
......
......@@ -33,6 +33,7 @@ def update_daily_exchange_contributions_info(date: Optional[datetime] = None):
university = University.objects.get(pk=contribution_profile.university_pk)
DailyExchangeContributionsInfo.objects.update_or_create(
date=date,
type=contribution_profile.type,
major=contribution_profile.major,
minor=contribution_profile.minor,
exchange_semester=contribution_profile.exchange_semester,
......
......@@ -67,3 +67,4 @@ class StatsContributionsTest(TestCase):
self.assertEqual(contribution.minor, "IDI")
self.assertEqual(contribution.exchange_semester, "A2019")
self.assertEqual(contribution.nb_contributions, 2)
self.assertEqual(contribution.type, "exchange_feedback")
......@@ -30,14 +30,16 @@ class ContributionProfile:
Class for keeping track a profile.
"""
type: str
major: str
minor: str
exchange_semester: str
university_pk: int
def _get_profile_from_exchange(exchange: Exchange) -> ContributionProfile:
def _get_profile_from_exchange(exchange: Exchange, type: str) -> ContributionProfile:
return ContributionProfile(
type=type,
major=exchange.student_major if exchange.student_major is not None else "",
minor=exchange.student_minor if exchange.student_minor is not None else "",
exchange_semester=f"{exchange.semester}{exchange.year}",
......@@ -64,7 +66,7 @@ def get_contributions_profiles(date: datetime) -> List[ContributionProfile]:
for exchange_feedback in exchange_feedbacks:
exchange = exchange_feedback.exchange
contribution_profile = _get_profile_from_exchange(exchange)
contribution_profile = _get_profile_from_exchange(exchange, "exchange_feedback")
contributions_profiles.append(contribution_profile)
course_feedbacks = CourseFeedback.objects.filter(
......@@ -75,7 +77,7 @@ def get_contributions_profiles(date: datetime) -> List[ContributionProfile]:
).prefetch_related("course__exchange")
for course_feedback in course_feedbacks:
exchange = course_feedback.course.exchange
contribution_profile = _get_profile_from_exchange(exchange)
contribution_profile = _get_profile_from_exchange(exchange, "course_feedback")
contributions_profiles.append(contribution_profile)
return contributions_profiles
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment