edx-enterprise-data 4.11.1__py3-none-any.whl → 5.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: edx-enterprise-data
3
- Version: 4.11.1
3
+ Version: 5.0.0
4
4
  Summary: Enterprise Reporting
5
5
  Home-page: https://github.com/openedx/edx-enterprise-data
6
6
  Author: edX
@@ -1,4 +1,4 @@
1
- enterprise_data/__init__.py,sha256=rYT7H9pEm0bjdfRQ5Sdbtq678rQ1BoDMVRYzJis1TFo,225
1
+ enterprise_data/__init__.py,sha256=9CalZxzrrlzN7gPjoqRg4WtrBoH9ajmbFp5PDXYl8wQ,224
2
2
  enterprise_data/apps.py,sha256=aF6hZwDfI2oWj95tUTm_2ikHueQj-jLj-u0GrgzpsQI,414
3
3
  enterprise_data/clients.py,sha256=GvQupy5TVYfO_IKC3yzXSAgNP54r-PtIjidM5ws9Iks,3947
4
4
  enterprise_data/constants.py,sha256=pS65L4mimz7hd_cLml_mXdU0GJ7hs0X8UQ8MNjC5hCU,234
@@ -17,7 +17,7 @@ enterprise_data/api/v0/views.py,sha256=4RslZ4NZOU-844bnebEQ71ji2utRY7jEijqC45oQQ
17
17
  enterprise_data/api/v1/__init__.py,sha256=4MKmD0y8ANRoaNzSYTwPFVCSfeid_bdzHCHnhR37MIs,144
18
18
  enterprise_data/api/v1/serializers.py,sha256=iLkuaXLRaRkfVyXch__IKXA3OIUH63QUNNGpXOjWPTk,6674
19
19
  enterprise_data/api/v1/urls.py,sha256=Vev34sBjvDSqGUuQQGTu-1ft-ISYUPO_GTOpx0RTiEA,1106
20
- enterprise_data/api/v1/views.py,sha256=bgDzbw8GpzFWfVSGg-AonIvTBg2HM776fBFr2sJO2wI,20563
20
+ enterprise_data/api/v1/views.py,sha256=7bGzQQO2CORVByKVORwhAIKhgjf1UMcTzz1VXmMXaTs,21475
21
21
  enterprise_data/fixtures/enterprise_enrollment.json,sha256=6onPXXR29pMdTdbl_mn81sDi3Re5jkLUZz2TPMB_1IY,5786
22
22
  enterprise_data/fixtures/enterprise_user.json,sha256=6g8GvNY9j_fh1dvAU80bTAMI2F5vXCkb8a4UjsftMvQ,1970
23
23
  enterprise_data/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -85,7 +85,7 @@ enterprise_data/tests/api/v0/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
85
85
  enterprise_data/tests/api/v0/test_serializers.py,sha256=Gfty6gy6OQLN318uL1OCPhAZOqSUL50FWc0nC23VMnc,6257
86
86
  enterprise_data/tests/api/v1/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
87
87
  enterprise_data/tests/api/v1/test_serializers.py,sha256=DwgEHcyOP3oqNUPB2O-NkJGeO_cYs9XJiq7791vJLZE,3682
88
- enterprise_data/tests/api/v1/test_views.py,sha256=_ex_Cn_aXN3UA3QboHCUnrwPNd3ZSF6nt_lnHPuYrH0,15158
88
+ enterprise_data/tests/api/v1/test_views.py,sha256=rLqUHfar0HdBNtz33hQxd_0qUUgr7Ku3KwQSQ1B4Ypg,15213
89
89
  enterprise_data_roles/__init__.py,sha256=toCpbypm2uDoWVw29_em9gPFNly8vNUS__C0b4TCqEg,112
90
90
  enterprise_data_roles/admin.py,sha256=QNP0VeWE092vZzpyxOA5UJK1nNGl5e71B1J0RCwo_nU,998
91
91
  enterprise_data_roles/apps.py,sha256=nKi8TyuQ5Q6WGtKs5QeXvUTc3N-YQjKhyBnm2EM3Bng,260
@@ -126,8 +126,8 @@ enterprise_reporting/tests/test_send_enterprise_reports.py,sha256=WtL-RqGgu2x5PP
126
126
  enterprise_reporting/tests/test_utils.py,sha256=7Y5GmeibiC8Q5kIpYuIAkFpeyIDRs2U3ItxsabhR1zM,9493
127
127
  enterprise_reporting/tests/test_vertica_client.py,sha256=-R2yNCGUjRtoXwLMBloVFQkFYrJoo613VCr61gwI3kQ,140
128
128
  enterprise_reporting/tests/utils.py,sha256=xms2LM7DV3wczXEfctOK1ddel1EE0J_YSr17UzbCDy4,1401
129
- edx_enterprise_data-4.11.1.dist-info/LICENSE,sha256=dql8h4yceoMhuzlcK0TT_i-NgTFNIZsgE47Q4t3dUYI,34520
130
- edx_enterprise_data-4.11.1.dist-info/METADATA,sha256=uErWJheUKOikIg83Sl9Bhzo0cJVwZK8kCpstii3fD1A,1490
131
- edx_enterprise_data-4.11.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
132
- edx_enterprise_data-4.11.1.dist-info/top_level.txt,sha256=f5F2kU-dob6MqiHJpgZkFzoCD5VMhsdpkTV5n9Tvq3I,59
133
- edx_enterprise_data-4.11.1.dist-info/RECORD,,
129
+ edx_enterprise_data-5.0.0.dist-info/LICENSE,sha256=dql8h4yceoMhuzlcK0TT_i-NgTFNIZsgE47Q4t3dUYI,34520
130
+ edx_enterprise_data-5.0.0.dist-info/METADATA,sha256=Lz8YW4ZkYhWJk6llJM1aMlVYR9vb5MiR6nk_R8DxB-o,1489
131
+ edx_enterprise_data-5.0.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
132
+ edx_enterprise_data-5.0.0.dist-info/top_level.txt,sha256=f5F2kU-dob6MqiHJpgZkFzoCD5VMhsdpkTV5n9Tvq3I,59
133
+ edx_enterprise_data-5.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.41.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -2,6 +2,6 @@
2
2
  Enterprise data api application. This Django app exposes API endpoints used by enterprises.
3
3
  """
4
4
 
5
- __version__ = "4.11.1"
5
+ __version__ = "5.0.0"
6
6
 
7
7
  default_app_config = "enterprise_data.apps.EnterpriseDataAppConfig" # pylint: disable=invalid-name
@@ -2,9 +2,9 @@
2
2
  Views for enterprise api v1.
3
3
  """
4
4
 
5
-
6
5
  from datetime import date, timedelta
7
6
  from logging import getLogger
7
+ from uuid import UUID
8
8
 
9
9
  from django_filters.rest_framework import DjangoFilterBackend
10
10
  from edx_django_utils.cache import TieredCache
@@ -181,7 +181,7 @@ class EnterpriseLearnerEnrollmentViewSet(EnterpriseViewSetMixin, viewsets.ReadOn
181
181
 
182
182
  offer_id = query_filters.get('offer_id')
183
183
  if offer_id:
184
- queryset = queryset.filter(offer_id=offer_id)
184
+ queryset = self.filter_by_offer_id(queryset, offer_id)
185
185
 
186
186
  ignore_null_course_list_price = query_filters.get('ignore_null_course_list_price')
187
187
  if ignore_null_course_list_price:
@@ -197,6 +197,27 @@ class EnterpriseLearnerEnrollmentViewSet(EnterpriseViewSetMixin, viewsets.ReadOn
197
197
 
198
198
  return queryset
199
199
 
200
+ def filter_by_offer_id(self, queryset, offer_id):
201
+ """
202
+ Filter queryset by `offer_id`
203
+ """
204
+ # offer_id field in table contains two types of data
205
+ # 1. integer
206
+ # 2. uuid
207
+ # In table, uuids are stored without hyphen and in lower case
208
+ # but api clients are sending uuids with hyphen and that causes the issue
209
+ # we need to remove the hyphens from uuid, convert the uuid to lower case and then do a compare in DB
210
+
211
+ # if offer_id is a uuid only then do the transformation
212
+ try:
213
+ offer_id_uuid_obj = UUID(offer_id, version=4)
214
+ offer_id = str(offer_id_uuid_obj)
215
+ offer_id = offer_id.replace('-', '')
216
+ except ValueError:
217
+ pass
218
+
219
+ return queryset.filter(offer_id=offer_id)
220
+
200
221
  def filter_active_enrollments(self, queryset):
201
222
  """
202
223
  Filters queryset to include enrollments with course date in future
@@ -471,7 +492,7 @@ class EnterpriseAdminInsightsView(APIView):
471
492
  """
472
493
  response_data = {}
473
494
  learner_progress = {}
474
- summary = {}
495
+ learner_engagement = {}
475
496
 
476
497
  try:
477
498
  learner_progress = EnterpriseAdminLearnerProgress.objects.get(enterprise_customer_uuid=enterprise_id)
@@ -481,14 +502,14 @@ class EnterpriseAdminInsightsView(APIView):
481
502
  pass
482
503
 
483
504
  try:
484
- summary = EnterpriseAdminSummarizeInsights.objects.get(enterprise_customer_uuid=enterprise_id)
485
- summary = serializers.EnterpriseAdminSummarizeInsightsSerializer(summary).data
486
- response_data['summary'] = summary
505
+ learner_engagement = EnterpriseAdminSummarizeInsights.objects.get(enterprise_customer_uuid=enterprise_id)
506
+ learner_engagement = serializers.EnterpriseAdminSummarizeInsightsSerializer(learner_engagement).data
507
+ response_data['learner_engagement'] = learner_engagement
487
508
  except EnterpriseAdminSummarizeInsights.DoesNotExist:
488
509
  pass
489
510
 
490
511
  status = HTTP_200_OK
491
- if learner_progress == {} and summary == {}:
512
+ if learner_progress == {} and learner_engagement == {}:
492
513
  status = HTTP_404_NOT_FOUND
493
514
 
494
515
  return Response(data=response_data, status=status)
@@ -338,7 +338,7 @@ class TestEnterpriseAdminInsightsView(JWTTestMixin, APITransactionTestCase):
338
338
  learner_progress_obj = EnterpriseAdminLearnerProgressFactory.create(
339
339
  enterprise_customer_uuid=enterprise_customer_uuid
340
340
  )
341
- summary_obj = EnterpriseAdminSummarizeInsightsFactory.create(
341
+ learner_engagement_obj = EnterpriseAdminSummarizeInsightsFactory.create(
342
342
  enterprise_customer_uuid=enterprise_customer_uuid
343
343
  )
344
344
 
@@ -350,8 +350,8 @@ class TestEnterpriseAdminInsightsView(JWTTestMixin, APITransactionTestCase):
350
350
 
351
351
  learner_progress = response_json['learner_progress']
352
352
  self.verify_data(learner_progress, learner_progress_obj)
353
- summary = response_json['summary']
354
- self.verify_data(summary, summary_obj)
353
+ learner_engagement = response_json['learner_engagement']
354
+ self.verify_data(learner_engagement, learner_engagement_obj)
355
355
 
356
356
  def test_retrieve_enterprise_admin_insights_no_data(self):
357
357
  """