From b5b4d422f5243f150cb9ea522342195c20497b5d Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 23 Jun 2023 09:18:59 +0300 Subject: [PATCH 1/6] Added missed auto_add argument --- .../migrations/0072_alter_issue_updated_date.py | 17 +++++++++++++++++ cvat/apps/engine/models.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 cvat/apps/engine/migrations/0072_alter_issue_updated_date.py diff --git a/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py b/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py new file mode 100644 index 000000000000..358f5d9fc487 --- /dev/null +++ b/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.1 on 2023-06-23 06:18 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("engine", "0071_annotationguide_asset"), + ] + + operations = [ + migrations.AlterField( + model_name="issue", + name="updated_date", + field=models.DateTimeField(auto_now=True, null=True), + ), + ] diff --git a/cvat/apps/engine/models.py b/cvat/apps/engine/models.py index c49a8aae67e5..39c5e46992be 100644 --- a/cvat/apps/engine/models.py +++ b/cvat/apps/engine/models.py @@ -994,7 +994,7 @@ class Issue(models.Model): assignee = models.ForeignKey(User, null=True, blank=True, related_name='+', on_delete=models.SET_NULL) created_date = models.DateTimeField(auto_now_add=True) - updated_date = models.DateTimeField(null=True, blank=True) + updated_date = models.DateTimeField(null=True, blank=True, auto_now=True) resolved = models.BooleanField(default=False) def get_project_id(self): From 04d13840bbd27ea4e9d4b69c15644160ab5e0531 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 23 Jun 2023 09:20:29 +0300 Subject: [PATCH 2/6] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6586069a36e2..7511e1028072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The problem with manifest file in tasks restored from backup () - The problem with task mode in a task restored from backup () - Visible 'To background' button in review mode () +- Added missed auto_add argument to Issue model () - \[API\] Performance of several API endpoints () - \[API\] Invalid schema for the owner field in several endpoints () From 8d7a8b7b8735daadfe6101c968d55c4812e01a07 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 23 Jun 2023 11:25:20 +0300 Subject: [PATCH 3/6] Added migration --- .../migrations/0072_alter_issue_updated_date.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py b/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py index 358f5d9fc487..4242638c40b0 100644 --- a/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py +++ b/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py @@ -2,6 +2,14 @@ from django.db import migrations, models +def forwards_func(apps, schema_editor): + Issue = apps.get_model("engine", "Issue") + + issues = Issue.objects.all() + for issue in issues: + issue.updated_date = issue.created_date + + Issue.objects.bulk_update(issues, fields=['updated_date'], batch_size=500) class Migration(migrations.Migration): dependencies = [ @@ -14,4 +22,7 @@ class Migration(migrations.Migration): name="updated_date", field=models.DateTimeField(auto_now=True, null=True), ), + migrations.RunPython( + code=forwards_func, + ), ] From c44e70cbf3b4dcbca84e913d036fbb126bf4c3c0 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 23 Jun 2023 22:28:23 +0300 Subject: [PATCH 4/6] updated fields & migration --- .../engine/migrations/0072_alter_issue_updated_date.py | 10 +++++----- cvat/apps/engine/models.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py b/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py index 4242638c40b0..4c549be10aa5 100644 --- a/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py +++ b/cvat/apps/engine/migrations/0072_alter_issue_updated_date.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.1 on 2023-06-23 06:18 +# Generated by Django 4.2.1 on 2023-06-23 19:26 from django.db import migrations, models @@ -17,12 +17,12 @@ class Migration(migrations.Migration): ] operations = [ + migrations.RunPython( + code=forwards_func, + ), migrations.AlterField( model_name="issue", name="updated_date", - field=models.DateTimeField(auto_now=True, null=True), - ), - migrations.RunPython( - code=forwards_func, + field=models.DateTimeField(auto_now=True), ), ] diff --git a/cvat/apps/engine/models.py b/cvat/apps/engine/models.py index 39c5e46992be..5e9f6781eb2c 100644 --- a/cvat/apps/engine/models.py +++ b/cvat/apps/engine/models.py @@ -994,7 +994,7 @@ class Issue(models.Model): assignee = models.ForeignKey(User, null=True, blank=True, related_name='+', on_delete=models.SET_NULL) created_date = models.DateTimeField(auto_now_add=True) - updated_date = models.DateTimeField(null=True, blank=True, auto_now=True) + updated_date = models.DateTimeField(auto_now=True) resolved = models.BooleanField(default=False) def get_project_id(self): From 11ff55694d9608b394b9b3222d60139247acc395 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Sat, 24 Jun 2023 08:49:09 +0300 Subject: [PATCH 5/6] updated test assets --- tests/python/shared/assets/cvat_db/data.json | 10 +++++----- tests/python/shared/assets/issues.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/python/shared/assets/cvat_db/data.json b/tests/python/shared/assets/cvat_db/data.json index 2613dacdc831..b33aad592e9c 100644 --- a/tests/python/shared/assets/cvat_db/data.json +++ b/tests/python/shared/assets/cvat_db/data.json @@ -9660,7 +9660,7 @@ ], "assignee": null, "created_date": "2022-03-16T11:04:39.444Z", - "updated_date": null, + "updated_date": "2022-03-16T11:04:39.444Z", "resolved": true } }, @@ -9676,7 +9676,7 @@ ], "assignee": null, "created_date": "2022-03-16T11:07:22.170Z", - "updated_date": null, + "updated_date": "2022-03-16T11:07:22.170Z", "resolved": false } }, @@ -9692,7 +9692,7 @@ ], "assignee": null, "created_date": "2022-03-16T11:08:18.367Z", - "updated_date": null, + "updated_date": "2022-03-16T11:08:18.367Z", "resolved": false } }, @@ -9710,7 +9710,7 @@ "user1" ], "created_date": "2022-03-16T12:40:00.764Z", - "updated_date": null, + "updated_date": "2022-03-16T12:40:00.764Z", "resolved": false } }, @@ -9726,7 +9726,7 @@ ], "assignee": null, "created_date": "2022-03-16T12:49:29.369Z", - "updated_date": null, + "updated_date": "2022-03-16T12:49:29.369Z", "resolved": false } }, diff --git a/tests/python/shared/assets/issues.json b/tests/python/shared/assets/issues.json index c924eee2df48..85575f9e8882 100644 --- a/tests/python/shared/assets/issues.json +++ b/tests/python/shared/assets/issues.json @@ -27,7 +27,7 @@ 362.6243902439037 ], "resolved": false, - "updated_date": null + "updated_date": "2022-03-16T12:49:29.369000Z" }, { "assignee": { @@ -59,7 +59,7 @@ 561.4921875 ], "resolved": false, - "updated_date": null + "updated_date": "2022-03-16T12:49:29.369000Z" }, { "assignee": null, @@ -85,7 +85,7 @@ 703.3505859375 ], "resolved": false, - "updated_date": null + "updated_date": "2022-03-16T12:49:29.369000Z" }, { "assignee": null, @@ -111,7 +111,7 @@ 841.5859375 ], "resolved": false, - "updated_date": null + "updated_date": "2022-03-16T12:49:29.369000Z" }, { "assignee": null, @@ -147,7 +147,7 @@ 319.63386727689067 ], "resolved": true, - "updated_date": null + "updated_date": "2022-03-16T12:49:29.369000Z" } ] } \ No newline at end of file From 565870f313ff3a477174d72ed9d8dbaffee9509b Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Sat, 24 Jun 2023 09:57:13 +0300 Subject: [PATCH 6/6] updated test assets --- tests/python/shared/assets/issues.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/python/shared/assets/issues.json b/tests/python/shared/assets/issues.json index 85575f9e8882..9aff3cf4b632 100644 --- a/tests/python/shared/assets/issues.json +++ b/tests/python/shared/assets/issues.json @@ -59,7 +59,7 @@ 561.4921875 ], "resolved": false, - "updated_date": "2022-03-16T12:49:29.369000Z" + "updated_date": "2022-03-16T12:40:00.764000Z" }, { "assignee": null, @@ -85,7 +85,7 @@ 703.3505859375 ], "resolved": false, - "updated_date": "2022-03-16T12:49:29.369000Z" + "updated_date": "2022-03-16T11:08:18.367000Z" }, { "assignee": null, @@ -111,7 +111,7 @@ 841.5859375 ], "resolved": false, - "updated_date": "2022-03-16T12:49:29.369000Z" + "updated_date": "2022-03-16T11:07:22.170000Z" }, { "assignee": null, @@ -147,7 +147,7 @@ 319.63386727689067 ], "resolved": true, - "updated_date": "2022-03-16T12:49:29.369000Z" + "updated_date": "2022-03-16T11:04:39.444000Z" } ] } \ No newline at end of file