From 96f3f333756765e74ec074d94c9f134d1ce80ab2 Mon Sep 17 00:00:00 2001 From: Ricardo Dahis Date: Thu, 7 Nov 2024 23:25:52 +1100 Subject: [PATCH 1/3] feat: closes #699 --- backend/apps/api/v1/admin.py | 1 + .../migrations/0051_remove_dataset_is_closed.py | 17 +++++++++++++++++ backend/apps/api/v1/models.py | 11 ++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py diff --git a/backend/apps/api/v1/admin.py b/backend/apps/api/v1/admin.py index 693fd77c..a440a65a 100644 --- a/backend/apps/api/v1/admin.py +++ b/backend/apps/api/v1/admin.py @@ -612,6 +612,7 @@ class DatasetAdmin(OrderedInlineModelAdminMixin, TabbedTranslationAdmin): "contains_tables", "contains_raw_data_sources", "contains_information_requests", + "contains_closed_data", "page_views", "created_at", "updated_at", diff --git a/backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py b/backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py new file mode 100644 index 00000000..2012247a --- /dev/null +++ b/backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.16 on 2024-11-07 12:24 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('v1', '0050_table_is_deprecated'), + ] + + operations = [ + migrations.RemoveField( + model_name='dataset', + name='is_closed', + ), + ] diff --git a/backend/apps/api/v1/models.py b/backend/apps/api/v1/models.py index c3233ddf..887e93b0 100644 --- a/backend/apps/api/v1/models.py +++ b/backend/apps/api/v1/models.py @@ -538,9 +538,6 @@ class Dataset(BaseModel): ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) - is_closed = models.BooleanField( - default=False, help_text="Dataset is for BD Pro subscribers only" - ) page_views = models.BigIntegerField( default=0, help_text="Number of page views by Google Analytics", @@ -662,14 +659,22 @@ def contains_closed_data(self): closed_data = False tables = self.tables.all() for table in tables: + # Check for closed coverages table_coverages = table.coverages.filter(is_closed=True) if table_coverages: closed_data = True break + + # Check for closed columns for column in table.columns.all(): if column.is_closed: # in the future it will be column.coverages closed_data = True break + + # Check if uncompressed file size is above 1 GB + if table.uncompressed_file_size and table.uncompressed_file_size > 1000000000: + closed_data = True + break return closed_data From b97a506012fc15901497f49b52b832c72d24a372 Mon Sep 17 00:00:00 2001 From: Ricardo Dahis Date: Mon, 11 Nov 2024 13:31:50 +1100 Subject: [PATCH 2/3] fix: property comment --- backend/apps/api/v1/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/apps/api/v1/models.py b/backend/apps/api/v1/models.py index 887e93b0..5b45c0b4 100644 --- a/backend/apps/api/v1/models.py +++ b/backend/apps/api/v1/models.py @@ -655,7 +655,7 @@ def contains_open_data(self): @property def contains_closed_data(self): - """Returns true if there are tables or columns with closed coverages""" + """Returns true if there are tables or columns with closed coverages, or if the uncompressed file size is above 1 GB""" closed_data = False tables = self.tables.all() for table in tables: From 6ab795bac64ce9cd79014be67a74c0c3e3c1d1c0 Mon Sep 17 00:00:00 2001 From: Ricardo Dahis Date: Mon, 25 Nov 2024 16:10:55 +1100 Subject: [PATCH 3/3] fix: migrations --- ...ve_dataset_is_closed.py => 0052_remove_dataset_is_closed.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename backend/apps/api/v1/migrations/{0051_remove_dataset_is_closed.py => 0052_remove_dataset_is_closed.py} (86%) diff --git a/backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py b/backend/apps/api/v1/migrations/0052_remove_dataset_is_closed.py similarity index 86% rename from backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py rename to backend/apps/api/v1/migrations/0052_remove_dataset_is_closed.py index 2012247a..e47b283f 100644 --- a/backend/apps/api/v1/migrations/0051_remove_dataset_is_closed.py +++ b/backend/apps/api/v1/migrations/0052_remove_dataset_is_closed.py @@ -6,7 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('v1', '0050_table_is_deprecated'), + ('v1', '0051_add_new_field_dataset'), ] operations = [