diff options
author | Max Magorsch <arzano@gentoo.org> | 2020-06-22 00:45:14 +0000 |
---|---|---|
committer | Max Magorsch <arzano@gentoo.org> | 2020-06-22 00:45:14 +0000 |
commit | 2149bb7fb6b6f732ac8364e45d072a22921957db (patch) | |
tree | b72b5b876489df7cbec280b06440b89f9fe46a2d /pkg/app/list/threads.go | |
parent | Improve the error handling during the import (diff) | |
download | archives-2149bb7fb6b6f732ac8364e45d072a22921957db.tar.gz archives-2149bb7fb6b6f732ac8364e45d072a22921957db.tar.bz2 archives-2149bb7fb6b6f732ac8364e45d072a22921957db.zip |
Rework the data model to improve the performance
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/app/list/threads.go')
-rw-r--r-- | pkg/app/list/threads.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/pkg/app/list/threads.go b/pkg/app/list/threads.go index 33ade3c..c069673 100644 --- a/pkg/app/list/threads.go +++ b/pkg/app/list/threads.go @@ -32,22 +32,21 @@ func Threads(w http.ResponseWriter, r *http.Request) { var messages []*models.Message query := database.DBCon.Model(&messages). - Column("id", "headers", "date"). + Column("id", "subject", "from", "date"). Where("to_char(date, 'YYYY-MM') = ?", combinedDate). - Where(`NOT headers::jsonb ? 'References'`). - Where(`NOT headers::jsonb ? 'In-Reply-To'`). + Where(`starts_thread = TRUE`). WhereGroup(func(q *orm.Query) (*orm.Query, error) { - q = q.WhereOr(`(headers::jsonb->>'Subject')::jsonb->>0 LIKE '[` + listName + `]%'`). - WhereOr(`(headers::jsonb->>'Subject')::jsonb->>0 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%'`) + 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 + //}). Order("date DESC") messagesCount, _ := query.Count() |