Skip to content

Commit

Permalink
fix: difference column for non-numeric
Browse files Browse the repository at this point in the history
  • Loading branch information
cabreraalex committed Sep 27, 2023
1 parent 71bf6bb commit 90a9718
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions backend/zeno_backend/database/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from psycopg import sql

from zeno_backend.classes.base import ZenoColumn
from zeno_backend.classes.base import MetadataType, ZenoColumn
from zeno_backend.classes.chart import Chart
from zeno_backend.classes.filter import FilterPredicateGroup, Join, Operation
from zeno_backend.classes.folder import Folder
Expand Down Expand Up @@ -1127,10 +1127,16 @@ def table_data_paginated(

diff_sql = sql.SQL("")
if req.diff_column_1 is not None and req.diff_column_2 is not None:
diff_sql = sql.SQL(", {} - {} AS diff").format(
sql.Identifier(req.diff_column_1.id),
sql.Identifier(req.diff_column_2.id),
)
if req.diff_column_1.data_type == MetadataType.CONTINUOUS:
diff_sql = sql.SQL(", {} - {} AS diff").format(
sql.Identifier(req.diff_column_1.id),
sql.Identifier(req.diff_column_2.id),
)
else:
diff_sql = sql.SQL(", {} = {} AS diff").format(
sql.Identifier(req.diff_column_1.id),
sql.Identifier(req.diff_column_2.id),
)

filter = sql.SQL("")
if filter_sql is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@
<td class="p-3 align-text-top">{modelValueAndDiff($comparisonModel, tableContent)}</td
>
<td class="p-3 align-text-top"
>{Number(tableContent['diff'])
>{$comparisonColumn?.dataType === MetadataType.CONTINUOUS
? Number(tableContent['diff']).toFixed(2)
: tableContent['diff']}</td
>
: tableContent['diff']}
</td>
{/if}
</tr>
{/each}
Expand Down

0 comments on commit 90a9718

Please sign in to comment.