Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/server/stats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ const getColumnValueByArea = async (
const valueSelect =
columnDef.type !== ColumnType.Number
? sql`MODE () WITHIN GROUP (ORDER BY json->>${column})`.as("value")
: db.fn(calculationType, [sql`(json->>${column})::float`]).as("value");
: db
.fn(calculationType, [
// Treat empty string as number 0
sql`(COALESCE(NULLIF(json->>${column}, ''), '0'))::float`,
])
.as("value");

const query = db
.selectFrom("dataRecord")
Expand Down