File tree Expand file tree Collapse file tree 4 files changed +24
-40
lines changed Expand file tree Collapse file tree 4 files changed +24
-40
lines changed Original file line number Diff line number Diff line change 1414 runs-on : ubuntu-24.04
1515 strategy :
1616 matrix :
17- python-version : ["3.12", "3.14 ", "3.14"]
17+ python-version : ["3.12", "3.13 ", "3.14"]
1818 steps :
1919 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2020 - name : Install uv
Original file line number Diff line number Diff line change @@ -56,10 +56,10 @@ function Calendar({
5656 ...classNames ,
5757 } }
5858 components = { {
59- Chevron : ( { orientation, ...props } ) => {
59+ Chevron : ( { className , orientation, ...props } ) => {
6060 const Icon =
6161 orientation === "left" ? ChevronLeft : ChevronRight ;
62- return < Icon className = "h-4 w-4" { ...props } /> ;
62+ return < Icon className = { cn ( "h-4 w-4" , className ) } { ...props } /> ;
6363 } ,
6464 } }
6565 { ...props }
Original file line number Diff line number Diff line change @@ -53,32 +53,15 @@ export async function fetchApiServer<T>(
5353 return null ;
5454 }
5555
56- // Special handling for endpoints that might return null
57- if (
58- endpoint . includes ( "/organizations/" ) &&
59- endpoint . includes ( "/sums" )
60- ) {
61- // For organization sums endpoint that might return null
62- try {
63- return await response . json ( ) ;
64- } catch ( e ) {
65- // If JSON parsing fails (e.g., empty response), return default values
66- console . warn (
67- "Empty response from organization sums endpoint, using default values" ,
68- ) ;
69- return {
70- name : "" ,
71- description : "" ,
72- emissions : 0 ,
73- energy_consumed : 0 ,
74- duration : 0 ,
75- cpu_power : 0 ,
76- gpu_power : 0 ,
77- ram_power : 0 ,
78- emissions_rate : 0 ,
79- emissions_count : 0 ,
80- } as unknown as T ;
81- }
56+ // Parse JSON response
57+ try {
58+ return await response . json ( ) ;
59+ } catch ( e ) {
60+ // If JSON parsing fails (e.g., empty response body), return null
61+ console . warn (
62+ `Empty or invalid JSON response from ${ endpoint } , returning null` ,
63+ ) ;
64+ return null ;
8265 }
8366 } catch ( error ) {
8467 // Log server-side error with more details
Original file line number Diff line number Diff line change @@ -13,19 +13,20 @@ export async function getOrganizationEmissionsByProject(
1313 endpoint += `?start_date=${ dateRange . from . toISOString ( ) } &end_date=${ dateRange . to . toISOString ( ) } ` ;
1414 }
1515
16- const result = await fetchApiServer < OrganizationReport > ( endpoint ) ;
16+ const result = await fetchApiServer < OrganizationReport > ( endpoint ) ;
1717
18- // Return empty data on failure (Pattern A - Read operation)
19- if ( ! result ) {
20- return {
21- name : "" ,
22- emissions : 0 ,
23- energy_consumed : 0 ,
24- duration : 0 ,
25- } ;
26- }
18+ // Handle case when no emissions data is found
19+ if ( ! result ) {
20+ // Return zeros for all metrics
21+ return {
22+ name : "" ,
23+ emissions : 0 ,
24+ energy_consumed : 0 ,
25+ duration : 0 ,
26+ } ;
27+ }
2728
28- return result ;
29+ return result ;
2930}
3031
3132export async function getDefaultOrgId ( ) : Promise < string | null > {
You can’t perform that action at this time.
0 commit comments