This repository was archived by the owner on May 12, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
src/routes/(protected)/consumers/[consumer_id]/rate-limits Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,7 +160,9 @@ export async function load(event: RequestEvent) {
160160 `/obp/v6.0.0/management/consumers/${ consumerId } /consumer/current-usage` ,
161161 token ,
162162 ) ;
163- logger . debug ( `Retrieved current usage for consumer` ) ;
163+ logger . debug (
164+ `Retrieved current usage: ${ JSON . stringify ( currentUsage ) } ` ,
165+ ) ;
164166 } catch ( e ) {
165167 logger . warn ( `Could not fetch current usage for consumer:` , e ) ;
166168 }
Original file line number Diff line number Diff line change 5353 }
5454
5555 function formatUsageValue(usageData : any , period : string ): string {
56- const periodData = usageData [period ];
57- const status = periodData .status ;
58- const value = periodData .calls_made ;
59-
60- if (status === " ACTIVE" ) {
56+ const value = usageData [period ];
57+ if (value === undefined || value === null ) {
58+ return " 0" ;
59+ }
60+ // Handle nested object structure with calls_made property
61+ if (typeof value === " object" && value .calls_made !== undefined ) {
62+ return String (value .calls_made );
63+ }
64+ // Handle simple numeric value
65+ if (typeof value === " number" ) {
6166 return String (value );
6267 }
63-
64- return status ;
68+ return " 0" ;
6569 }
6670
6771 function isUsageActive(usageData : any , period : string ): boolean {
68- return usageData [period ]?.status === " ACTIVE" ;
72+ const value = usageData [period ];
73+ if (value === undefined || value === null ) {
74+ return false ;
75+ }
76+ // Handle nested object structure
77+ if (typeof value === " object" && value .status !== undefined ) {
78+ return value .status === " ACTIVE" ;
79+ }
80+ // Handle simple numeric value
81+ return true ;
6982 }
7083 </script >
7184
You can’t perform that action at this time.
0 commit comments