From 59932ebe201994b7fc37649335c4ef6791eba06a Mon Sep 17 00:00:00 2001 From: Akhil Gupta Date: Tue, 23 Mar 2021 06:49:40 +0530 Subject: [PATCH] fix breaking filter --- db/dbfunctions.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/db/dbfunctions.go b/db/dbfunctions.go index b2e8c07..82b44e2 100644 --- a/db/dbfunctions.go +++ b/db/dbfunctions.go @@ -60,19 +60,22 @@ func GetPaginatedPodcastItemsNew(queryModel model.EpisodesFilter) (*[]PodcastIte query := DB.Debug().Preload("Podcast") if queryModel.IsDownloaded != nil { isDownloaded, err := strconv.ParseBool(*queryModel.IsDownloaded) - if err == nil && isDownloaded { - query = query.Where("download_status=?", Downloaded) - } else { - query = query.Where("download_status!=?", Downloaded) + if err == nil { + if isDownloaded { + query = query.Where("download_status=?", Downloaded) + } else { + query = query.Where("download_status!=?", Downloaded) + } } } if queryModel.IsPlayed != nil { isPlayed, err := strconv.ParseBool(*queryModel.IsPlayed) - - if err == nil && isPlayed { - query = query.Where("is_played=?", 1) - } else { - query = query.Where("is_played=?", 0) + if err == nil { + if isPlayed { + query = query.Where("is_played=?", 1) + } else { + query = query.Where("is_played=?", 0) + } } }