1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-14 22:47:21 +00:00

Move almost all functions' parameter db.Engine to context.Context (#19748)

* Move almost all functions' parameter db.Engine to context.Context
* remove some unnecessary wrap functions
This commit is contained in:
Lunny Xiao
2022-05-20 22:08:52 +08:00
committed by GitHub
parent d81e31ad78
commit fd7d83ace6
232 changed files with 1463 additions and 2108 deletions

View File

@ -34,7 +34,7 @@ func GetNotificationCount(c *context.Context) {
}
c.Data["NotificationUnreadCount"] = func() int64 {
count, err := models.GetNotificationCount(c.Doer, models.NotificationStatusUnread)
count, err := models.GetNotificationCount(c, c.Doer, models.NotificationStatusUnread)
if err != nil {
c.ServerError("GetNotificationCount", err)
return -1
@ -79,7 +79,7 @@ func getNotifications(c *context.Context) {
status = models.NotificationStatusUnread
}
total, err := models.GetNotificationCount(c.Doer, status)
total, err := models.GetNotificationCount(c, c.Doer, status)
if err != nil {
c.ServerError("ErrGetNotificationCount", err)
return
@ -93,7 +93,7 @@ func getNotifications(c *context.Context) {
}
statuses := []models.NotificationStatus{status, models.NotificationStatusPinned}
notifications, err := models.NotificationsForUser(c.Doer, statuses, page, perPage)
notifications, err := models.NotificationsForUser(c, c.Doer, statuses, page, perPage)
if err != nil {
c.ServerError("ErrNotificationsForUser", err)
return
@ -195,5 +195,5 @@ func NotificationPurgePost(c *context.Context) {
// NewAvailable returns the notification counts
func NewAvailable(ctx *context.Context) {
ctx.JSON(http.StatusOK, structs.NotificationCount{New: models.CountUnread(ctx.Doer)})
ctx.JSON(http.StatusOK, structs.NotificationCount{New: models.CountUnread(ctx, ctx.Doer.ID)})
}