From acd8a85c3a4010afb71ce45e1b3cd475900b70e6 Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Sat, 16 Dec 2023 02:18:15 +0700 Subject: [PATCH] palomar: filter out 'future' content from post queries --- search/query.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/search/query.go b/search/query.go index 9bbb384bd..45ae6434c 100644 --- a/search/query.go +++ b/search/query.go @@ -7,11 +7,13 @@ import ( "fmt" "io/ioutil" "log/slog" + "time" "github.com/bluesky-social/indigo/atproto/identity" - "go.opentelemetry.io/otel/attribute" + "github.com/bluesky-social/indigo/atproto/syntax" es "github.com/opensearch-project/opensearch-go/v2" + "go.opentelemetry.io/otel/attribute" ) type EsSearchHit struct { @@ -73,6 +75,15 @@ func DoSearchPosts(ctx context.Context, dir identity.Directory, escli *es.Client "analyze_wildcard": false, }, } + // filter out future posts (TODO: temporary hack) + today := syntax.DatetimeNow().Time().Format(time.DateOnly) + filters = append(filters, map[string]interface{}{ + "range": map[string]interface{}{ + "created_at": map[string]interface{}{ + "lte": today, + }, + }, + }) query := map[string]interface{}{ "query": map[string]interface{}{ "bool": map[string]interface{}{