Skip to content

Commit

Permalink
Merge pull request #715 from basedosdados/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rdahis authored Nov 25, 2024
2 parents 4def8eb + 6097717 commit 37a337d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 25 deletions.
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
19 changes: 19 additions & 0 deletions backend/apps/api/v1/migrations/0051_add_new_field_dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.16 on 2024-11-13 16:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('v1', '0050_table_is_deprecated'),
]

operations = [
migrations.AddField(
model_name='dataset',
name='usage_guide',
field=models.TextField(blank=True, null=True, default='', max_length=255 , verbose_name='Guia de Uso')
),
]

21 changes: 0 additions & 21 deletions backend/apps/api/v1/migrations/0051_add_textfield_all_models.py

This file was deleted.

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',
),
]
14 changes: 10 additions & 4 deletions backend/apps/api/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,11 @@ 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",
)
usage_guide = models.TextField(blank=True, null=True, default='', max_length=255 , verbose_name='Guia de Uso')

graphql_nested_filter_fields_whitelist = ["id", "slug"]

Expand Down Expand Up @@ -658,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

0 comments on commit 37a337d

Please sign in to comment.