Move database logic into separate subdirectory
I'm trying to see if this speeds up builds a bit. May not without a module boundary, but for now it's nice organization to have as the program grows.
This commit is contained in:
parent
338f90708e
commit
41587c3694
333 changed files with 206 additions and 200 deletions
|
|
@ -6,8 +6,9 @@ import (
|
|||
"log/slog"
|
||||
"time"
|
||||
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/enums"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/aarondl/opt/omit"
|
||||
"github.com/aarondl/opt/omitnull"
|
||||
)
|
||||
|
|
@ -34,7 +35,7 @@ func clearNotificationsOauth(ctx context.Context, user *models.User) {
|
|||
models.UpdateWhere.Notifications.UserID.EQ(user.ID),
|
||||
setter.UpdateMod(),
|
||||
)
|
||||
updater.Exec(ctx, PGInstance.BobDB)
|
||||
updater.Exec(ctx, db.PGInstance.BobDB)
|
||||
//user.UserNotifications(
|
||||
//models.SelectWhere.Notifications.Link.EQ(NotificationPathOauthReset),
|
||||
//).UpdateAll()
|
||||
|
|
@ -47,7 +48,7 @@ func notifyOauthInvalid(ctx context.Context, user *models.User) {
|
|||
Link: omit.From(NotificationPathOauthReset),
|
||||
Type: omit.From(enums.NotificationtypeOauthTokenInvalidated),
|
||||
}
|
||||
err := user.InsertUserNotifications(ctx, PGInstance.BobDB, ¬ificationSetter)
|
||||
err := user.InsertUserNotifications(ctx, db.PGInstance.BobDB, ¬ificationSetter)
|
||||
if err != nil {
|
||||
LogErrorTypeInfo(err)
|
||||
slog.Error("Failed to insert new notification. Update this clause to detect duplicate inserts.", slog.String("err", err.Error()))
|
||||
|
|
@ -59,7 +60,7 @@ func notificationsForUser(ctx context.Context, u *models.User) ([]Notification,
|
|||
results := make([]Notification, 0)
|
||||
notifications, err := u.UserNotifications(
|
||||
models.SelectWhere.Notifications.ResolvedAt.IsNull(),
|
||||
).All(ctx, PGInstance.BobDB)
|
||||
).All(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
return results, fmt.Errorf("Failed to get notifications: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue