MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / fetchGrowthStage

Function fetchGrowthStage

src/components/FieldDetailView.tsx:151–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 const cached = cache[fieldId];
150 if (cached && Date.now() - cached.timestamp < 3600000) { setData(cached.data); return; }
151 const fetchGrowthStage = async () => {
152 setLoading(true);
153 try {
154 const result = await invokeWithRetry<any>(
155 "ndvi-timeseries",
156 { polygon },
157 { retries: 3, isEmpty: (d: any) => !d?.growth_stage }
158 );
159 const gs = result?.growth_stage ? {
160 stage: result.growth_stage, progress: result.growth_progress,
161 current_ndvi: result.latest_ndvi, date_range: result.date_range,
162 } : null;
163 setData(gs);
164 if (gs) setCache(GROWTH_STAGE_CACHE_KEY, fieldId, gs);
165 } catch (e) { console.error("Growth stage error:", e); setData(null); }
166 finally { setLoading(false); }
167 };
168 fetchGrowthStage();
169 }, [fieldId]);
170

Callers 1

GrowthStageSectionFunction · 0.85

Calls 1

setCacheFunction · 0.85

Tested by

no test coverage detected