diff options
author | 2020-06-23 15:47:11 +0200 | |
---|---|---|
committer | 2020-06-23 15:47:11 +0200 | |
commit | e82baa3d0262e8c01658935453aee6a2d96d8311 (patch) | |
tree | fc6e81d2daee11b35c41587ffa0a571e27039b96 | |
parent | Clean up the code (diff) | |
download | archives-e82baa3d0262e8c01658935453aee6a2d96d8311.tar.gz archives-e82baa3d0262e8c01658935453aee6a2d96d8311.tar.bz2 archives-e82baa3d0262e8c01658935453aee6a2d96d8311.zip |
Speed up loading the messages for a list
Signed-off-by: Max Magorsch <arzano@gentoo.org>
-rw-r--r-- | pkg/app/list/messages.go | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/pkg/app/list/messages.go b/pkg/app/list/messages.go index 7a78811..a9564a8 100644 --- a/pkg/app/list/messages.go +++ b/pkg/app/list/messages.go @@ -3,7 +3,6 @@ package list import ( "archives/pkg/database" "archives/pkg/models" - "github.com/go-pg/pg/v10/orm" "math" "net/http" "strconv" @@ -35,18 +34,7 @@ func Messages(w http.ResponseWriter, r *http.Request) { query := database.DBCon.Model(&messages). Column("id", "subject", "from", "date"). Where("to_char(date, 'YYYY-MM') = ?", combinedDate). - WhereGroup(func(q *orm.Query) (*orm.Query, error) { - q = q.WhereOr(`subject LIKE '[` + listName + `]%'`). - WhereOr(`subject LIKE 'Re: [` + listName + `]%'`) - return q, nil - }). - //WhereGroup(func(q *orm.Query) (*orm.Query, error) { - // q = q.WhereOr(`headers::jsonb->>'To' LIKE '%` + listName + `@lists.gentoo.org%'`). - // WhereOr(`headers::jsonb->>'Cc' LIKE '%` + listName + `@lists.gentoo.org%'`). - // WhereOr(`headers::jsonb->>'To' LIKE '%` + listName + `@gentoo.org%'`). - // WhereOr(`headers::jsonb->>'Cc' LIKE '%` + listName + `@gentoo.org%'`) - // return q, nil - //}). + Where("list = ?", listName). Order("date DESC") messagesCount, _ := query.Count() |