mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
Related refactors to ctx.FormX functions (#16567)
* use FormTrim if posible * speedup goGet * only convert if nessesary
This commit is contained in:
parent
2d25b7d44b
commit
f1a810e090
22 changed files with 36 additions and 52 deletions
|
@ -171,7 +171,7 @@ func ReadRepoNotifications(ctx *context.APIContext) {
|
|||
// "$ref": "#/responses/empty"
|
||||
|
||||
lastRead := int64(0)
|
||||
qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ")
|
||||
qLastRead := ctx.FormTrim("last_read_at")
|
||||
if len(qLastRead) > 0 {
|
||||
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
|
||||
if err != nil {
|
||||
|
|
|
@ -6,7 +6,6 @@ package notify
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -122,7 +121,7 @@ func ReadNotifications(ctx *context.APIContext) {
|
|||
// "$ref": "#/responses/empty"
|
||||
|
||||
lastRead := int64(0)
|
||||
qLastRead := strings.Trim(ctx.FormString("last_read_at"), " ")
|
||||
qLastRead := ctx.FormTrim("last_read_at")
|
||||
if len(qLastRead) > 0 {
|
||||
tmpLastRead, err := time.Parse(time.RFC3339, qLastRead)
|
||||
if err != nil {
|
||||
|
|
|
@ -8,7 +8,6 @@ package org
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
@ -658,7 +657,7 @@ func SearchTeam(ctx *context.APIContext) {
|
|||
|
||||
opts := &models.SearchTeamOptions{
|
||||
UserID: ctx.User.ID,
|
||||
Keyword: strings.TrimSpace(ctx.FormString("q")),
|
||||
Keyword: ctx.FormTrim("q"),
|
||||
OrgID: ctx.Org.Organization.ID,
|
||||
IncludeDesc: ctx.FormString("include_desc") == "" || ctx.FormBool("include_desc"),
|
||||
ListOptions: listOptions,
|
||||
|
|
|
@ -140,7 +140,7 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
var issues []*models.Issue
|
||||
var filteredCount int64
|
||||
|
||||
keyword := strings.Trim(ctx.FormString("q"), " ")
|
||||
keyword := ctx.FormTrim("q")
|
||||
if strings.IndexByte(keyword, 0) >= 0 {
|
||||
keyword = ""
|
||||
}
|
||||
|
@ -162,13 +162,13 @@ func SearchIssues(ctx *context.APIContext) {
|
|||
isPull = util.OptionalBoolNone
|
||||
}
|
||||
|
||||
labels := strings.TrimSpace(ctx.FormString("labels"))
|
||||
labels := ctx.FormTrim("labels")
|
||||
var includedLabelNames []string
|
||||
if len(labels) > 0 {
|
||||
includedLabelNames = strings.Split(labels, ",")
|
||||
}
|
||||
|
||||
milestones := strings.TrimSpace(ctx.FormString("milestones"))
|
||||
milestones := ctx.FormTrim("milestones")
|
||||
var includedMilestones []string
|
||||
if len(milestones) > 0 {
|
||||
includedMilestones = strings.Split(milestones, ",")
|
||||
|
@ -331,7 +331,7 @@ func ListIssues(ctx *context.APIContext) {
|
|||
var issues []*models.Issue
|
||||
var filteredCount int64
|
||||
|
||||
keyword := strings.Trim(ctx.FormString("q"), " ")
|
||||
keyword := ctx.FormTrim("q")
|
||||
if strings.IndexByte(keyword, 0) >= 0 {
|
||||
keyword = ""
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ package repo
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
|
@ -90,7 +89,7 @@ func ListTrackedTimes(ctx *context.APIContext) {
|
|||
IssueID: issue.ID,
|
||||
}
|
||||
|
||||
qUser := strings.Trim(ctx.FormString("user"), " ")
|
||||
qUser := ctx.FormTrim("user")
|
||||
if qUser != "" {
|
||||
user, err := models.GetUserByName(qUser)
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
@ -500,7 +499,7 @@ func ListTrackedTimesByRepository(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
// Filters
|
||||
qUser := strings.Trim(ctx.FormString("user"), " ")
|
||||
qUser := ctx.FormTrim("user")
|
||||
if qUser != "" {
|
||||
user, err := models.GetUserByName(qUser)
|
||||
if models.IsErrUserNotExist(err) {
|
||||
|
|
|
@ -135,7 +135,7 @@ func Search(ctx *context.APIContext) {
|
|||
opts := &models.SearchRepoOptions{
|
||||
ListOptions: utils.GetListOptions(ctx),
|
||||
Actor: ctx.User,
|
||||
Keyword: strings.Trim(ctx.FormString("q"), " "),
|
||||
Keyword: ctx.FormTrim("q"),
|
||||
OwnerID: ctx.FormInt64("uid"),
|
||||
PriorityOwnerID: ctx.FormInt64("priority_owner_id"),
|
||||
TeamID: ctx.FormInt64("team_id"),
|
||||
|
|
|
@ -8,7 +8,6 @@ package user
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
|
@ -58,7 +57,7 @@ func Search(ctx *context.APIContext) {
|
|||
|
||||
opts := &models.SearchUserOptions{
|
||||
Actor: ctx.User,
|
||||
Keyword: strings.Trim(ctx.FormString("q"), " "),
|
||||
Keyword: ctx.FormTrim("q"),
|
||||
UID: ctx.FormInt64("uid"),
|
||||
Type: models.UserTypeIndividual,
|
||||
ListOptions: listOptions,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue