Skip to content

Commit

Permalink
Rename attribute to dataset_attribute of shorterm forecast data and u…
Browse files Browse the repository at this point in the history
…pdate Diagram (#91)

* Rename attribute to dataset_attribute of shorterm forecast data

* Update database diagram
  • Loading branch information
meomancer committed Aug 13, 2024
1 parent e896a26 commit a3d9b28
Show file tree
Hide file tree
Showing 10 changed files with 1,398 additions and 325 deletions.
2 changes: 1 addition & 1 deletion django_project/gap/factories/crop_insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Meta: # noqa
model = FarmShortTermForecastData

forecast = factory.SubFactory(FarmShortTermForecastFactory)
attribute = factory.SubFactory(DatasetAttributeFactory)
dataset_attribute = factory.SubFactory(DatasetAttributeFactory)
value_date = factory.Faker('date')
value = factory.Faker('pyfloat')

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2024-08-13 02:08

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('gap', '0006_datasettype_variable_name'),
]

operations = [
migrations.AlterModelOptions(
name='farmshorttermforecastdata',
options={'ordering': ['dataset_attribute', '-value_date']},
),
migrations.RenameField(
model_name='farmshorttermforecastdata',
old_name='attribute',
new_name='dataset_attribute',
),
]
8 changes: 4 additions & 4 deletions django_project/gap/models/crop_insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FarmShortTermForecastData(models.Model):
forecast = models.ForeignKey(
FarmShortTermForecast, on_delete=models.CASCADE
)
attribute = models.ForeignKey(
dataset_attribute = models.ForeignKey(
DatasetAttribute, on_delete=models.CASCADE,
help_text='Forecast attribute'
)
Expand All @@ -73,7 +73,7 @@ class FarmShortTermForecastData(models.Model):
)

class Meta: # noqa: D106
ordering = ['attribute', '-value_date']
ordering = ['dataset_attribute', '-value_date']


class FarmProbabilisticWeatherForcast(models.Model):
Expand Down Expand Up @@ -290,7 +290,7 @@ def data(self):
if key not in output:
output[key] = {}
output[key][
data.attribute.attribute.variable_name
data.dataset_attribute.attribute.variable_name
] = data.value
return output

Expand Down Expand Up @@ -370,7 +370,7 @@ def generate_report(self):
different = data.value_date - first_date
curr_idx = different.days * 3 # 3 columns per day
curr_idx += first_columns_count
var = data.attribute.source
var = data.dataset_attribute.source
if var == 'temperatureMax':
curr_idx += 1
elif var == 'rainAccumulationSum':
Expand Down
2 changes: 1 addition & 1 deletion django_project/spw/generator/crop_insight.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def generate_spw(self):
FarmShortTermForecastData.objects.update_or_create(
forecast=c,
value_date=_date,
attribute=attr,
dataset_attribute=attr,
defaults={
'value': val
}
Expand Down
4 changes: 2 additions & 2 deletions docs/src/developer/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ license: This program is free software; you can redistribute it and/or modify it

## GAP

![database design gap](./diagram/ground-observations-database-design-1.png)
![database design gap](./diagram/solution-design-app-0018-Database-GAP.drawio.png)

## SPW

![database design spw](./diagram/ground-observations-database-design-2.png)
![database design spw](./diagram/solution-design-app-0018-Database-SPW.drawio.png)

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,685 changes: 1,368 additions & 317 deletions docs/src/developer/diagram/solution-design-app-0018.drawio

Large diffs are not rendered by default.

0 comments on commit a3d9b28

Please sign in to comment.