Browse Source

fix: restore avg wind and capacity factor for overview page data

zhouyang.xie 1 tuần trước cách đây
mục cha
commit
06f1f2ff75
1 tập tin đã thay đổi với 4 bổ sung và 1 xóa
  1. 4 1
      app/report/page_source.py

+ 4 - 1
app/report/page_source.py

@@ -139,6 +139,8 @@ def collect_overview_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[
             avg_power = _f(row.get("avg_power") or row.get("active_power_avg") or 0)
             avg_wind = _f(row.get("avg_wind") or row.get("WindSpeedAvr") or row.get("wind_velocity") or None)
             points = int(_f(row.get("points") or row.get("record_count") or 0) or 0)
+            if points <= 0 and avg_wind is not None:
+                points = 1
             if not name and not month:
                 continue
             total_kwh += gen_kwh
@@ -212,7 +214,8 @@ def collect_overview_from_page(wind: Dict[str, Any], months: List[str]) -> Dict[
         "total_mwh": round(total_mwh, 2),
         "equivalent_hours": round(total_kwh / capacity, 1) if capacity else None,
         "avg_wind": round(weighted_wind / total_points, 2) if total_points else None,
-        "capacity_factor": None,
+        "capacity_factor": round(total_mwh * 1000 / (capacity * 24 * 30.4 * len(months)) * 100, 2)
+        if capacity and months else None,
         "completeness": round(comp_total_valid / comp_total_expected * 100, 2) if comp_total_expected else None,
         "integrity_files": integ_files,
     }