Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: contains closed resources #705

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/apps/api/v1/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions backend/apps/api/v1/migrations/0052_remove_dataset_is_closed.py
Original file line number Diff line number Diff line change
@@ -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', '0051_add_new_field_dataset'),
]

operations = [
migrations.RemoveField(
model_name='dataset',
name='is_closed',
),
]
13 changes: 9 additions & 4 deletions backend/apps/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -659,18 +656,26 @@ 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:
# 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

Expand Down
Loading