Skip to content

Commit

Permalink
Merge pull request breatheco-de#1218 from gustavomm19/delivered_at
Browse files Browse the repository at this point in the history
add delivered_at to tasks
  • Loading branch information
jefer94 authored Dec 14, 2023
2 parents c252581 + 1a30d2a commit fb46d32
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 12 deletions.
4 changes: 3 additions & 1 deletion breathecode/activity/tests/urls/v2/tests_academy_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
UTC_NOW = timezone.now()


def bigquery_client_mock(self, n=1, user_id=1, kind=None):
def bigquery_client_mock(self, n=1, user_id=1, kind=None, date_start=None, date_end=None):
rows_to_insert = [{
'id': uuid4().hex,
'user_id': user_id,
Expand Down Expand Up @@ -51,6 +51,8 @@ def bigquery_client_mock(self, n=1, user_id=1, kind=None):
WHERE user_id = @user_id
AND meta.academy = @academy_id
{'AND kind = @kind' if kind else ''}
{'AND timestamp >= @date_start' if date_start else ''}
{'AND timestamp <= @date_end' if date_end else ''}
ORDER BY id DESC
LIMIT @limit
OFFSET @offset
Expand Down
36 changes: 25 additions & 11 deletions breathecode/admissions/tests/urls/tests_academy_cohort_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,17 +916,31 @@ def test__with_data__with_cohorts_get_tasks_with_no_tasks(self):
'phone': model['profile_academy'].phone,
},
'tasks': [{
'id': model['task'].id,
'associated_slug': model['task'].associated_slug,
'description': model['task'].description,
'github_url': model['task'].github_url,
'live_url': model['task'].live_url,
'task_type': model['task'].task_type,
'task_status': model['task'].task_status,
'revision_status': model['task'].revision_status,
'created_at': re.sub(r'\+00:00$', 'Z', model['task'].created_at.isoformat()),
'updated_at': re.sub(r'\+00:00$', 'Z', model['task'].updated_at.isoformat()),
'title': model['task'].title,
'id':
model['task'].id,
'associated_slug':
model['task'].associated_slug,
'description':
model['task'].description,
'github_url':
model['task'].github_url,
'live_url':
model['task'].live_url,
'task_type':
model['task'].task_type,
'task_status':
model['task'].task_status,
'revision_status':
model['task'].revision_status,
'created_at':
re.sub(r'\+00:00$', 'Z', model['task'].created_at.isoformat()),
'updated_at':
re.sub(r'\+00:00$', 'Z', model['task'].updated_at.isoformat()),
'delivered_at':
re.sub(r'\+00:00$', 'Z', model['task'].delivered_at.isoformat())
if model['task'].delivered_at is not None else None,
'title':
model['task'].title,
}],
'cohort': {
'id': model['cohort_user'].cohort.id,
Expand Down
18 changes: 18 additions & 0 deletions breathecode/assignments/migrations/0016_task_delivered_at.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.23 on 2023-12-14 00:35

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('assignments', '0015_auto_20231017_0605'),
]

operations = [
migrations.AddField(
model_name='task',
name='delivered_at',
field=models.DateTimeField(blank=True, db_index=True, default=None, null=True),
),
]
1 change: 1 addition & 0 deletions breathecode/assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Task(models.Model):
live_url = models.CharField(max_length=150, blank=True, default=None, null=True)
description = models.TextField(max_length=450, blank=True)
opened_at = models.DateTimeField(null=True, blank=True, default=None, db_index=True)
delivered_at = models.DateTimeField(null=True, blank=True, default=None, db_index=True)

subtasks = models.JSONField(
default=None,
Expand Down
2 changes: 2 additions & 0 deletions breathecode/assignments/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class TaskGETSerializer(serpy.Serializer):
task_type = serpy.Field()
user = UserSmallSerializer()
opened_at = serpy.Field()
delivered_at = serpy.Field()

created_at = serpy.Field()
updated_at = serpy.Field()
Expand All @@ -61,6 +62,7 @@ class TaskGETSmallSerializer(serpy.Serializer):
github_url = serpy.Field()
live_url = serpy.Field()
task_type = serpy.Field()
delivered_at = serpy.Field()

created_at = serpy.Field()
updated_at = serpy.Field()
Expand Down
2 changes: 2 additions & 0 deletions breathecode/assignments/tests/urls/tests_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def get_serializer(self, task, user):
'title': task.title,
'description': task.description,
'opened_at': self.bc.datetime.to_iso_string(task.opened_at) if task.opened_at else task.opened_at,
'delivered_at':
self.bc.datetime.to_iso_string(task.delivered_at) if task.delivered_at else task.delivered_at,
'user': {
'first_name': user.first_name,
'id': user.id,
Expand Down
6 changes: 6 additions & 0 deletions breathecode/assignments/tests/urls/tests_task_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def get_serializer(self, task, user):
'title': task.title,
'description': task.description,
'opened_at': self.bc.datetime.to_iso_string(task.opened_at) if task.opened_at else task.opened_at,
'delivered_at':
self.bc.datetime.to_iso_string(task.delivered_at) if task.delivered_at else task.delivered_at,
'user': {
'first_name': user.first_name,
'id': user.id,
Expand Down Expand Up @@ -51,6 +53,8 @@ def put_serializer(self, task, data={}):
'title': task.title,
'rigobot_repository_id': task.rigobot_repository_id,
'opened_at': self.bc.datetime.to_iso_string(task.opened_at) if task.opened_at else task.opened_at,
'delivered_at':
self.bc.datetime.to_iso_string(task.delivered_at) if task.delivered_at else task.delivered_at,
**data,
}

Expand All @@ -70,6 +74,8 @@ def task_row(self, task, data={}):
'user_id': task.user.id,
'subtasks': task.subtasks,
'opened_at': self.bc.datetime.to_iso_string(task.opened_at) if task.opened_at else task.opened_at,
'delivered_at':
self.bc.datetime.to_iso_string(task.delivered_at) if task.delivered_at else task.delivered_at,
'rigobot_repository_id': task.rigobot_repository_id,
**data,
}
Expand Down
4 changes: 4 additions & 0 deletions breathecode/assignments/tests/urls/tests_user_me_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def get_serializer(self, task, user):
'title': task.title,
'description': task.description,
'opened_at': self.bc.datetime.to_iso_string(task.opened_at) if task.opened_at else task.opened_at,
'delivered_at':
self.bc.datetime.to_iso_string(task.delivered_at) if task.delivered_at else task.delivered_at,
'user': {
'first_name': user.first_name,
'id': user.id,
Expand All @@ -78,6 +80,8 @@ def put_serializer(self, task, data={}):
'attachments': [],
'subtasks': task.subtasks,
'opened_at': self.bc.datetime.to_iso_string(task.opened_at) if task.opened_at else task.opened_at,
'delivered_at':
self.bc.datetime.to_iso_string(task.delivered_at) if task.delivered_at else task.delivered_at,
**data,
}

Expand Down

0 comments on commit fb46d32

Please sign in to comment.