Refacto document filter

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2025-08-05 10:48:55 +02:00
parent 7e59504462
commit 036970afdd

View File

@@ -39,25 +39,15 @@ func NewDocumentTrustCenterFilter() *DocumentFilter {
} }
func (f *DocumentFilter) SQLArguments() pgx.StrictNamedArgs { func (f *DocumentFilter) SQLArguments() pgx.StrictNamedArgs {
args := pgx.StrictNamedArgs{} return pgx.StrictNamedArgs{
"query": f.query,
if f.query != nil { "show_on_trust_center": f.showOnTrustCenter,
args["query"] = *f.query
} else {
args["query"] = (*string)(nil)
} }
if f.showOnTrustCenter != nil {
args["show_on_trust_center"] = *f.showOnTrustCenter
} else {
args["show_on_trust_center"] = (*bool)(nil)
}
return args
} }
func (f *DocumentFilter) SQLFragment() string { func (f *DocumentFilter) SQLFragment() string {
sql := `( return `
(
CASE CASE
WHEN @query::text IS NOT NULL AND @query::text != '' THEN WHEN @query::text IS NOT NULL AND @query::text != '' THEN
search_vector @@ ( search_vector @@ (
@@ -73,6 +63,4 @@ func (f *DocumentFilter) SQLFragment() string {
ELSE TRUE ELSE TRUE
END END
)` )`
return sql
} }