Skip to content

Commit

Permalink
Don't fetch data without siteUUIDS
Browse files Browse the repository at this point in the history
  • Loading branch information
braddf committed Jul 13, 2023
1 parent d862be8 commit 0ba2195
Show file tree
Hide file tree
Showing 2 changed files with 319 additions and 19 deletions.
24 changes: 15 additions & 9 deletions lib/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export function useSitesGeneration(sites: Site[]) {
error: manyForecastError,
isLoading: isManyForecastLoading,
} = useSWR(
`${
process.env.NEXT_PUBLIC_API_BASE_URL_GET
}/sites/pv_forecast?site_uuids=${siteUUIDs.join(',')}`,
siteUUIDs.length
? `${
process.env.NEXT_PUBLIC_API_BASE_URL_GET
}/sites/pv_forecast?site_uuids=${siteUUIDs.join(',')}`
: null,
manyForecastDataFetcher
);

Expand All @@ -70,9 +72,11 @@ export function useSitesGeneration(sites: Site[]) {
error: manyClearskyError,
isLoading: isManyClearskyLoading,
} = useSWR(
`${
process.env.NEXT_PUBLIC_API_BASE_URL_GET
}/sites/clearsky_estimate?site_uuids=${siteUUIDs.join(',')}`,
siteUUIDs.length
? `${
process.env.NEXT_PUBLIC_API_BASE_URL_GET
}/sites/clearsky_estimate?site_uuids=${siteUUIDs.join(',')}`
: null,
manyClearskyDataFetcher
);

Expand All @@ -81,9 +85,11 @@ export function useSitesGeneration(sites: Site[]) {
error: manyActualError,
isLoading: isManyActualLoading,
} = useSWR(
`${
process.env.NEXT_PUBLIC_API_BASE_URL_GET
}/sites/pv_actual?site_uuids=${siteUUIDs.join(',')}`,
siteUUIDs.length
? `${
process.env.NEXT_PUBLIC_API_BASE_URL_GET
}/sites/pv_actual?site_uuids=${siteUUIDs.join(',')}`
: null,
manyActualsFetcher
);

Expand Down
Loading

0 comments on commit 0ba2195

Please sign in to comment.