Skip to content

Commit

Permalink
Add gdd fixtures (#346)
Browse files Browse the repository at this point in the history
* Add gdd ingestor

* Add fixtures for GDDConfig, GDDMatrix and Crop; Refcatored unique_together constraint

* rm GDD traces

* fix: pk values with names

* rm dependency
  • Loading branch information
osundwajeff authored Jan 14, 2025
1 parent 35dbabc commit 5b7ef14
Show file tree
Hide file tree
Showing 5 changed files with 1,762 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2025-01-14 12:49

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dcas', '0004_dcasrequest_dcasoutput_dcaserrorlog'),
]

operations = [
migrations.AlterUniqueTogether(
name='gddmatrix',
unique_together={('crop', 'crop_stage_type', 'config', 'crop_growth_stage', 'gdd_threshold')},
),
]
8 changes: 7 additions & 1 deletion django_project/dcas/models/gdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,10 @@ class Meta:

db_table = 'gdd_matrix'
verbose_name = 'GDD Matrix'
unique_together = ('crop', 'crop_stage_type', 'config')
unique_together = (
'crop',
'crop_stage_type',
'config',
'crop_growth_stage',
'gdd_threshold'
)
72 changes: 72 additions & 0 deletions django_project/gap/fixtures/14.crop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"model": "gap.crop",
"pk": 2,
"fields": {
"name": "Maize"
}
},
{
"model": "gap.crop",
"pk": 8,
"fields": {
"name": "Finger Millet"
}
},
{
"model": "gap.crop",
"pk": 6,
"fields": {
"name": "Sorghum"
}
},
{
"model": "gap.crop",
"pk": 10,
"fields": {
"name": "Cassava"
}
},
{
"model": "gap.crop",
"pk": 3,
"fields": {
"name": "Potatoes"
}
},
{
"model": "gap.crop",
"pk": 5,
"fields": {
"name": "Sunflower"
}
},
{
"model": "gap.crop",
"pk": 7,
"fields": {
"name": "Soybeans"
}
},
{
"model": "gap.crop",
"pk": 4,
"fields": {
"name": "Green Grams"
}
},
{
"model": "gap.crop",
"pk": 9,
"fields": {
"name": "Cowpea"
}
},
{
"model": "gap.crop",
"pk": 1,
"fields": {
"name": "Common Beans"
}
}
]
102 changes: 102 additions & 0 deletions django_project/gap/fixtures/15.gdd_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
{
"model": "dcas.gddconfig",
"pk": 1,
"fields": {
"crop": 2,
"base_temperature": 10,
"cap_temperature": 35,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 2,
"fields": {
"crop": 8,
"base_temperature": 9,
"cap_temperature": 25,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 3,
"fields": {
"crop": 6,
"base_temperature": 10,
"cap_temperature": 35,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 4,
"fields": {
"crop": 10,
"base_temperature": 12,
"cap_temperature": 35,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 5,
"fields": {
"crop": 3,
"base_temperature": 4.5,
"cap_temperature": 20,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 6,
"fields": {
"crop": 5,
"base_temperature": 10,
"cap_temperature": 30,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 7,
"fields": {
"crop": 7,
"base_temperature": 10,
"cap_temperature": 30,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 8,
"fields": {
"crop": 4,
"base_temperature": 10,
"cap_temperature": 35,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 9,
"fields": {
"crop": 9,
"base_temperature": 10,
"cap_temperature": 30,
"config": 1
}
},
{
"model": "dcas.gddconfig",
"pk": 10,
"fields": {
"crop": 1,
"base_temperature": 10,
"cap_temperature": 30,
"config": 1
}
}
]
Loading

0 comments on commit 5b7ef14

Please sign in to comment.