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

Function fetchTs

src/components/FieldComparisonColumn.tsx:128–148  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

126 return;
127 }
128 const fetchTs = async () => {
129 setNdviTsLoading(true);
130 try {
131 const polygon = field.coordinates[0];
132 const { data, error } = await supabase.functions.invoke("ndvi-timeseries", {
133 body: { polygon },
134 });
135 if (error) throw error;
136 if (hasNdviPayload(data)) {
137 setNdviTimeSeries(data);
138 setLocalCache(GEE_ANALYTICS_CACHE_KEY, cacheKey, data);
139 } else if (isFallbackPayload(data)) {
140 setNdviTimeSeries(cached ?? null);
141 } else {
142 setNdviTimeSeries(null);
143 }
144 } catch (e) {
145 console.error("NDVI time-series error:", e);
146 setNdviTimeSeries(cached ?? null);
147 } finally { setNdviTsLoading(false); }
148 };
149 fetchTs();
150 }, [field.id]);
151

Callers 1

FieldComparisonColumnFunction · 0.70

Calls 3

hasNdviPayloadFunction · 0.90
setLocalCacheFunction · 0.90
isFallbackPayloadFunction · 0.90

Tested by

no test coverage detected