Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
58f450d1
Commit
58f450d1
authored
Apr 21, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Add Decimal JSON serialization handler for analytics charts
parent
b4bc6fb6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
2 deletions
+15
-2
analytics.py
aisbf/analytics.py
+8
-1
antani_sqlite_db_3f9c7e7f.sqlite3
antani_sqlite_db_3f9c7e7f.sqlite3
+0
-0
main.py
main.py
+7
-1
No files found.
aisbf/analytics.py
View file @
58f450d1
...
...
@@ -23,6 +23,7 @@ Why did the programmer quit his job? Because he didn't get arrays!
Token Usage Analytics module for AISBF.
"""
import
json
from
decimal
import
Decimal
import
csv
import
io
from
typing
import
Dict
,
List
,
Optional
,
Any
...
...
@@ -1113,7 +1114,13 @@ class Analytics:
'recommendations'
:
self
.
get_optimization_recommendations
()
}
return
json
.
dumps
(
data
,
indent
=
2
)
# Handle Decimal values from MySQL for JSON serialization
def
decimal_default
(
obj
):
if
isinstance
(
obj
,
Decimal
):
return
float
(
obj
)
raise
TypeError
(
f
"Object of type {obj.__class__.__name__} is not JSON serializable"
)
return
json
.
dumps
(
data
,
indent
=
2
,
default
=
decimal_default
)
def
export_to_csv
(
self
,
...
...
antani_sqlite_db_3f9c7e7f.sqlite3
0 → 100644
View file @
58f450d1
main.py
View file @
58f450d1
from
decimal
import
Decimal
"""
Copyleft (C) 2026 Stefy Lanza <stefy@nexlab.net>
...
...
@@ -2228,7 +2229,12 @@ async def dashboard_analytics(
"session"
:
request
.
session
,
"is_admin"
:
is_admin
,
"provider_stats"
:
provider_stats
,
"token_over_time"
:
json
.
dumps
(
token_over_time
),
# Handle Decimal values from MySQL for JSON serialization
def
decimal_default
(
obj
):
if
isinstance
(
obj
,
Decimal
):
return
int
(
obj
)
raise
TypeError
(
f
"Object of type {obj.__class__.__name__} is not JSON serializable"
)
"token_over_time"
:
json
.
dumps
(
token_over_time
,
default
=
decimal_default
),
"model_performance"
:
model_performance
,
"cost_overview"
:
cost_overview
,
"recommendations"
:
recommendations
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment