From 595186b1b28310d6f77b8a659a21bb02c930e0c2 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 1 Dec 2023 21:56:14 -0500 Subject: [PATCH] Coalesce null annotation values, to better rank them against annotations with value 0 --- persistence/sql_annotations.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/persistence/sql_annotations.go b/persistence/sql_annotations.go index 8e26fcf7..58c35965 100644 --- a/persistence/sql_annotations.go +++ b/persistence/sql_annotations.go @@ -19,7 +19,13 @@ func (r sqlRepository) newSelectWithAnnotation(idField string, options ...model. "annotation.item_id = "+idField+ " AND annotation.item_type = '"+r.tableName+"'"+ " AND annotation.user_id = '"+userId(r.ctx)+"')"). - Columns("starred", "starred_at", "play_count", "play_date", "rating") + Columns( + "coalesce(starred, 0) as starred", + "coalesce(rating, 0) as rating", + "coalesce(play_count, 0) as play_count", + "starred_at", + "play_date", + ) } func (r sqlRepository) annId(itemID ...string) And {