aboutsummaryrefslogtreecommitdiff
path: root/pkg/app
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-06-23 15:46:59 +0200
committerMax Magorsch <arzano@gentoo.org>2020-06-23 15:46:59 +0200
commit55301d30a5c47291cafe84f483324510ee9151b4 (patch)
tree4fdabd11c8788568bf37c6b15cf5072d72ca30ec /pkg/app
parentImprove the importer further (diff)
downloadarchives-55301d30a5c47291cafe84f483324510ee9151b4.tar.gz
archives-55301d30a5c47291cafe84f483324510ee9151b4.tar.bz2
archives-55301d30a5c47291cafe84f483324510ee9151b4.zip
Clean up the code
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/app')
-rw-r--r--pkg/app/home/home.go7
-rw-r--r--pkg/app/home/utils.go7
-rw-r--r--pkg/app/list/show.go7
-rw-r--r--pkg/app/list/threads.go7
-rw-r--r--pkg/app/list/utils.go18
-rw-r--r--pkg/app/popular/utils.go23
6 files changed, 0 insertions, 69 deletions
diff --git a/pkg/app/home/home.go b/pkg/app/home/home.go
index 6d86095..d0d3582 100644
--- a/pkg/app/home/home.go
+++ b/pkg/app/home/home.go
@@ -34,13 +34,6 @@ func ComputeTemplateData() interface{} {
WhereOr(`subject LIKE 'Re: [` + mailingList[0] + `]%'`)
return q, nil
}).
- //WhereGroup(func(q *orm.Query) (*orm.Query, error) {
- // q = q.WhereOr(`headers::jsonb->>'To' LIKE '%` + mailingList[0] + `@lists.gentoo.org%'`).
- // WhereOr(`headers::jsonb->>'Cc' LIKE '%` + mailingList[0] + `@lists.gentoo.org%'`).
- // WhereOr(`headers::jsonb->>'To' LIKE '%` + mailingList[0] + `@gentoo.org%'`).
- // WhereOr(`headers::jsonb->>'Cc' LIKE '%` + mailingList[0] + `@gentoo.org%'`)
- // return q, nil
- //}).
Order("date DESC").
Limit(5).
Select()
diff --git a/pkg/app/home/utils.go b/pkg/app/home/utils.go
index 767b60d..76af3c7 100644
--- a/pkg/app/home/utils.go
+++ b/pkg/app/home/utils.go
@@ -16,13 +16,6 @@ func renderIndexTemplate(w http.ResponseWriter, templateData interface{}) {
templates := template.Must(
template.Must(
template.New("Show").
- Funcs(template.FuncMap{
- "makeMessage": func(headers map[string][]string) models.Message {
- return models.Message{
- //Headers: headers,
- }
- },
- }).
ParseGlob("web/templates/layout/*.tmpl")).
ParseGlob("web/templates/home/*.tmpl"))
diff --git a/pkg/app/list/show.go b/pkg/app/list/show.go
index 5231b5b..79ea8f2 100644
--- a/pkg/app/list/show.go
+++ b/pkg/app/list/show.go
@@ -31,13 +31,6 @@ func ComputeShowTemplateData(listName string) interface{} {
WhereOr(`subject LIKE 'Re: [` + listName + `]%'`)
return q, nil
}).
- //WhereGroup(func(q *orm.Query) (*orm.Query, error) {
- // q = q.WhereOr(`to LIKE '%` + listName + `@lists.gentoo.org%'`).
- // WhereOr(`cc LIKE '%` + listName + `@lists.gentoo.org%'`).
- // WhereOr(`to LIKE '%` + listName + `@gentoo.org%'`).
- // WhereOr(`cc LIKE '%` + listName + `@gentoo.org%'`)
- // return q, nil
- //}).
ColumnExpr("to_char(date, 'YYYY-MM') AS combined_date").
ColumnExpr("count(*) AS message_count").
Group("combined_date").
diff --git a/pkg/app/list/threads.go b/pkg/app/list/threads.go
index c069673..dfc9694 100644
--- a/pkg/app/list/threads.go
+++ b/pkg/app/list/threads.go
@@ -40,13 +40,6 @@ func Threads(w http.ResponseWriter, r *http.Request) {
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()
diff --git a/pkg/app/list/utils.go b/pkg/app/list/utils.go
index 07dbc65..8a9e964 100644
--- a/pkg/app/list/utils.go
+++ b/pkg/app/list/utils.go
@@ -3,9 +3,7 @@
package list
import (
- "archives/pkg/database"
"archives/pkg/models"
- "github.com/go-pg/pg/v10/orm"
"html/template"
"net/http"
)
@@ -119,19 +117,3 @@ func makeRange(min, max int) []int {
}
return a
}
-
-func countMessages(listName string) (int, error) {
- return database.DBCon.Model((*models.Message)(nil)).
- 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%'`)
- return q, nil
- }).Count()
-}
diff --git a/pkg/app/popular/utils.go b/pkg/app/popular/utils.go
index bc2a12f..5af1c2f 100644
--- a/pkg/app/popular/utils.go
+++ b/pkg/app/popular/utils.go
@@ -5,7 +5,6 @@ import (
"archives/pkg/models"
"html/template"
"net/http"
- "strconv"
)
// renderIndexTemplate renders all templates used for the landing page
@@ -13,13 +12,6 @@ func renderPopularThreads(w http.ResponseWriter, templateData interface{}) {
templates := template.Must(
template.Must(
template.New("Popular").
- Funcs(template.FuncMap{
- "makeMessage": func(headers map[string][]string) models.Message {
- return models.Message{
- //Headers: headers,
- }
- },
- }).
ParseGlob("web/templates/layout/*.tmpl")).
ParseGlob("web/templates/popular/*.tmpl"))
@@ -39,18 +31,3 @@ func GetPopularThreads(n int, date string) ([]*models.Message, error) {
return recentMessages, err
}
-
-func GetMessagesFromPopularThreads(threads models.Threads) []*models.Message {
- var popularThreads []*models.Message
- for _, thread := range threads {
- var messages []*models.Message
- err := database.DBCon.Model(&messages).
- Where(`headers::jsonb->>'Subject' LIKE '%` + thread.Id + `%'`).
- Select()
- if err == nil && len(messages) > 0 {
- messages[0].Comment = strconv.Itoa(thread.Count)
- popularThreads = append(popularThreads, messages[0])
- }
- }
- return popularThreads
-}