Skip to content

Commit 5335bd1

Browse files
authored
Merge pull request #705 from basedosdados/feat/closed_resources
feat: contains closed resources
2 parents 5b67528 + 6ab795b commit 5335bd1

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

backend/apps/api/v1/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ class DatasetAdmin(OrderedInlineModelAdminMixin, TabbedTranslationAdmin):
612612
"contains_tables",
613613
"contains_raw_data_sources",
614614
"contains_information_requests",
615+
"contains_closed_data",
615616
"page_views",
616617
"created_at",
617618
"updated_at",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 4.2.16 on 2024-11-07 12:24
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('v1', '0051_add_new_field_dataset'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='dataset',
15+
name='is_closed',
16+
),
17+
]

backend/apps/api/v1/models.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,6 @@ class Dataset(BaseModel):
538538
)
539539
created_at = models.DateTimeField(auto_now_add=True)
540540
updated_at = models.DateTimeField(auto_now=True)
541-
is_closed = models.BooleanField(
542-
default=False, help_text="Dataset is for BD Pro subscribers only"
543-
)
544541
page_views = models.BigIntegerField(
545542
default=0,
546543
help_text="Number of page views by Google Analytics",
@@ -659,18 +656,26 @@ def contains_open_data(self):
659656

660657
@property
661658
def contains_closed_data(self):
662-
"""Returns true if there are tables or columns with closed coverages"""
659+
"""Returns true if there are tables or columns with closed coverages, or if the uncompressed file size is above 1 GB"""
663660
closed_data = False
664661
tables = self.tables.all()
665662
for table in tables:
663+
# Check for closed coverages
666664
table_coverages = table.coverages.filter(is_closed=True)
667665
if table_coverages:
668666
closed_data = True
669667
break
668+
669+
# Check for closed columns
670670
for column in table.columns.all():
671671
if column.is_closed: # in the future it will be column.coverages
672672
closed_data = True
673673
break
674+
675+
# Check if uncompressed file size is above 1 GB
676+
if table.uncompressed_file_size and table.uncompressed_file_size > 1000000000:
677+
closed_data = True
678+
break
674679

675680
return closed_data
676681

0 commit comments

Comments
 (0)