mirror of
https://github.com/axllent/mailpit.git
synced 2026-03-03 02:17:01 +00:00
Code cleanup
This commit is contained in:
@@ -27,7 +27,7 @@ func ReindexAll() {
|
||||
err := sqlf.Select("ID").To(&i).
|
||||
From(tenant("mailbox")).
|
||||
OrderBy("Created DESC").
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {
|
||||
ids = append(ids, i)
|
||||
})
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ func SettingGet(k string) string {
|
||||
Select("Value").To(&result).
|
||||
Where("Key = ?", k).
|
||||
Limit(1).
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {})
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {})
|
||||
if err != nil {
|
||||
logger.Log().Errorf("[db] %s", err.Error())
|
||||
return ""
|
||||
@@ -41,7 +41,7 @@ func getDeletedSize() uint64 {
|
||||
Select("Value").To(&result).
|
||||
Where("Key = ?", "DeletedSize").
|
||||
Limit(1).
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {})
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {})
|
||||
if err != nil {
|
||||
logger.Log().Errorf("[db] %s", err.Error())
|
||||
return 0
|
||||
@@ -55,7 +55,7 @@ func totalMessagesSize() uint64 {
|
||||
var result sql.NullFloat64
|
||||
err := sqlf.From(tenant("mailbox")).
|
||||
Select("SUM(Size)").To(&result).
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {})
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {})
|
||||
if err != nil {
|
||||
logger.Log().Errorf("[db] %s", err.Error())
|
||||
return 0
|
||||
|
||||
@@ -147,7 +147,7 @@ func GetAllTags() []string {
|
||||
Select(`DISTINCT Name`).
|
||||
From(tenant("tags")).To(&name).
|
||||
OrderBy("Name").
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {
|
||||
tags = append(tags, name)
|
||||
}); err != nil {
|
||||
logger.Log().Errorf("[db] %s", err.Error())
|
||||
@@ -169,7 +169,7 @@ func GetAllTagsCount() map[string]int64 {
|
||||
LeftJoin(tenant("message_tags"), tenant("tags.ID")+" = "+tenant("message_tags.TagID")).
|
||||
GroupBy(tenant("message_tags.TagID")).
|
||||
OrderBy("Name").
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {
|
||||
tags[name] = int64(total)
|
||||
}); err != nil {
|
||||
logger.Log().Errorf("[db] %s", err.Error())
|
||||
@@ -352,7 +352,7 @@ func getMessageTags(id string) []string {
|
||||
LeftJoin(tenant("message_tags"), tenant("Tags.ID")+"="+tenant("message_tags.TagID")).
|
||||
Where(tenant("message_tags.ID")+` = ?`, id).
|
||||
OrderBy("Name").
|
||||
QueryAndClose(context.TODO(), db, func(row *sql.Rows) {
|
||||
QueryAndClose(context.TODO(), db, func(_ *sql.Rows) {
|
||||
tags = append(tags, name)
|
||||
}); err != nil {
|
||||
logger.Log().Errorf("[tags] %s", err.Error())
|
||||
|
||||
@@ -130,14 +130,14 @@ func TestAPIv1ToggleReadStatus(t *testing.T) {
|
||||
|
||||
// read first 10 IDs
|
||||
t.Log("Get first 10 IDs")
|
||||
putIDS := []string{}
|
||||
putIDs := []string{}
|
||||
for idx, msg := range m.Messages {
|
||||
if idx == 10 {
|
||||
break
|
||||
}
|
||||
|
||||
// store for later
|
||||
putIDS = append(putIDS, msg.ID)
|
||||
putIDs = append(putIDs, msg.ID)
|
||||
}
|
||||
assertStatsEqual(t, ts.URL+"/api/v1/messages", 100, 100)
|
||||
|
||||
@@ -145,7 +145,7 @@ func TestAPIv1ToggleReadStatus(t *testing.T) {
|
||||
t.Log("Mark first 10 as read")
|
||||
putData := putDataStruct
|
||||
putData.Read = true
|
||||
putData.IDs = putIDS
|
||||
putData.IDs = putIDs
|
||||
j, err := json.Marshal(putData)
|
||||
if err != nil {
|
||||
t.Error(err.Error())
|
||||
|
||||
Reference in New Issue
Block a user