[performance] Speed up some of the slower db queries (#523)

* remove unnecessary LOWER() db calls

* warn during slow db queries

* use bundb built-in exists function

* add db block test

* update account block query

* add domain block db test

* optimize domain block query

* fix implementing wrong test

* exclude most columns when checking block

* go fmt

* remote more unnecessary use of LOWER()
This commit is contained in:
tobi
2022-05-02 12:53:46 +02:00
committed by GitHub
parent faae2505c0
commit a5852fd7e4
13 changed files with 151 additions and 29 deletions

View File

@ -22,6 +22,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
@ -35,13 +36,15 @@ func (m *Module) StatusGETHandler(c *gin.Context) {
"url": c.Request.RequestURI,
})
requestedUsername := c.Param(UsernameKey)
// usernames on our instance are always lowercase
requestedUsername := strings.ToLower(c.Param(UsernameKey))
if requestedUsername == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no username specified in request"})
return
}
requestedStatusID := c.Param(StatusIDKey)
// status IDs on our instance are always uppercase
requestedStatusID := strings.ToUpper(c.Param(StatusIDKey))
if requestedStatusID == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "no status id specified in request"})
return