update chicken weight to have chicken_area data as well
This commit is contained in:
1 parent
a6d4ddac65
commit
6bad900cf0
13 files changed
+132
-21
No files matched your search
@@ -283,6 +283,7 @@ class Command(BaseCommand):
|
||||
weight = AVG_WEIGHT[i]
|
||||
prev_weight = AVG_WEIGHT[i - 1] if i > 0 else DOC_IN_WEIGHT
|
||||
adg = _round(weight - prev_weight, 2) if weight else 0.0
|
||||
area_cm2 = _round(4.8 * (weight ** 0.66), 1) if weight else 0.0
|
||||
cw, _ = ChickenWeight.objects.update_or_create(
|
||||
cycle=cycle,
|
||||
date=day,
|
||||
@@ -293,6 +294,7 @@ class Command(BaseCommand):
|
||||
"chicken_count": SAMPLE_COUNT[i],
|
||||
"uniformity": UNIFORMITY[i],
|
||||
"average_daily_gain": adg,
|
||||
"chicken_area": area_cm2,
|
||||
},
|
||||
)
|
||||
cw_by_date[day] = cw
|
||||
|
||||
@@ -147,16 +147,18 @@ class Command(BaseCommand):
|
||||
|
||||
cw_by_date = {}
|
||||
for row in sheets["chicken_weight"]:
|
||||
avg_wt = float(as_number(row.get("average_weight")))
|
||||
obj, _ = ChickenWeight.objects.update_or_create(
|
||||
cycle=cycle,
|
||||
date=row["date"],
|
||||
defaults={
|
||||
"age": int(as_number(row.get("age"))),
|
||||
"doc_weight": int(as_number(row.get("doc_weight"))),
|
||||
"average_weight": float(as_number(row.get("average_weight"))),
|
||||
"average_weight": avg_wt,
|
||||
"chicken_count": int(as_number(row.get("chicken_count"))),
|
||||
"uniformity": float(as_number(row.get("uniformity"))),
|
||||
"average_daily_gain": float(as_number(row.get("average_daily_gain"))),
|
||||
"chicken_area": round(4.8 * (avg_wt ** 0.66), 1) if avg_wt > 0 else 0.0,
|
||||
},
|
||||
)
|
||||
cw_by_date[row["date"]] = obj
|
||||
|
||||
Reference in new issue
Block a user