Skip to content

Commit

Permalink
averages
Browse files Browse the repository at this point in the history
  • Loading branch information
Cufee committed Jun 6, 2024
1 parent 3058e8d commit 40b3413
Show file tree
Hide file tree
Showing 23 changed files with 488 additions and 86 deletions.
31 changes: 24 additions & 7 deletions cmds/core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,32 @@ import (
"golang.org/x/text/language"
)

type Client struct {
Fetch fetch.Client
DB database.Client
var _ Client = &client{}

type Client interface {
Render(locale language.Tag) stats.Renderer

Database() database.Client
Fetch() fetch.Client
}

type client struct {
fetch fetch.Client
db database.Client
}

func (c *client) Database() database.Client {
return c.db
}

func (c *client) Fetch() fetch.Client {
return c.fetch
}

func (c *Client) Render(locale language.Tag) stats.Renderer {
return stats.NewRenderer(c.Fetch, locale)
func (c *client) Render(locale language.Tag) stats.Renderer {
return stats.NewRenderer(c.fetch, locale)
}

func NewClient(fetch fetch.Client, database database.Client) Client {
return Client{Fetch: fetch, DB: database}
func NewClient(fetch fetch.Client, database database.Client) *client {
return &client{fetch: fetch, db: database}
}
44 changes: 44 additions & 0 deletions cmds/core/scheduler/cron.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package scheduler

import (
"time"

"github.com/cufee/aftermath/cmds/core"
"github.com/go-co-op/gocron"
"github.com/rs/zerolog/log"
)

func StartCronJobs(client core.Client) {
log.Info().Msg("starting cron jobs")

c := gocron.NewScheduler(time.UTC)
// Tasks
c.Cron("* * * * *").Do(runTasksWorker(client))
c.Cron("0 * * * *").Do(restartTasksWorker(client))

// Glossary - Do it around the same time WG releases game updates
c.Cron("0 10 * * *").Do(UpdateGlossaryWorker(client))
c.Cron("0 12 * * *").Do(UpdateGlossaryWorker(client))
// c.AddFunc("40 9 * * 0", updateAchievementsWorker)

// Averages - Update averages shortly after session refreshes
c.Cron("0 10 * * *").Do(UpdateAveragesWorker(client))
c.Cron("0 2 * * *").Do(UpdateAveragesWorker(client))
c.Cron("0 19 * * *").Do(UpdateAveragesWorker(client))

// Sessions
c.Cron("0 9 * * *").Do(createSessionTasksWorker(client, "NA")) // NA
c.Cron("0 1 * * *").Do(createSessionTasksWorker(client, "EU")) // EU
c.Cron("0 18 * * *").Do(createSessionTasksWorker(client, "AS")) // Asia

// Refresh WN8
// "45 9 * * *" // NA
// "45 1 * * *" // EU
// "45 18 * * *" // Asia

// Configurations
c.Cron("0 0 */7 * *").Do(rotateBackgroundPresetsWorker(client))

// Start the Cron job scheduler
c.StartAsync()
}
48 changes: 48 additions & 0 deletions cmds/core/scheduler/glossary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package scheduler

import (
"context"
"time"

"github.com/cufee/aftermath/cmds/core"
"github.com/rs/zerolog/log"
)

// CurrentTankAverages

func UpdateAveragesWorker(client core.Client) func() {
return func() {
log.Info().Msg("updating tank averages cache")

ctx, cancel := context.WithTimeout(context.Background(), time.Minute*1)
defer cancel()

// we just run the logic directly as it's not a heavy task and it doesn't matter if it fails
averages, err := client.Fetch().CurrentTankAverages(ctx)
if err != nil {
log.Err(err).Msg("failed to update averages cache")
return
}

err = client.Database().UpsertVehicleAverages(ctx, averages)
if err != nil {
log.Err(err).Msg("failed to update averages cache")
return
}

log.Info().Msg("averages cache updated")
}
}

func UpdateGlossaryWorker(client core.Client) func() {
return func() {
// // We just run the logic directly as it's not a heavy task and it doesn't matter if it fails due to the app failing
// log.Info().Msg("updating glossary cache")
// err := cache.UpdateGlossaryCache()
// if err != nil {
// log.Err(err).Msg("failed to update glossary cache")
// } else {
// log.Info().Msg("glossary cache updated")
// }
}
}
68 changes: 68 additions & 0 deletions cmds/core/scheduler/workers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package scheduler

import (
"github.com/cufee/aftermath/cmds/core"
)

func rotateBackgroundPresetsWorker(client core.Client) func() {
return func() {
// // We just run the logic directly as it's not a heavy task and it doesn't matter if it fails due to the app failing
// log.Info().Msg("rotating background presets")
// images, err := content.PickRandomBackgroundImages(3)
// if err != nil {
// log.Err(err).Msg("failed to pick random background images")
// return
// }
// err = database.UpdateAppConfiguration[[]string]("backgroundImagesSelection", images, nil, true)
// if err != nil {
// log.Err(err).Msg("failed to update background images selection")
// }
}
}

func createSessionTasksWorker(client core.Client, realm string) func() {
return func() {
// err := tasks.CreateSessionUpdateTasks(realm)
// if err != nil {
// log.Err(err).Msg("failed to create session update tasks")
// }
}
}

func runTasksWorker(client core.Client) func() {
return func() {
// if tasks.DefaultQueue.ActiveWorkers() > 0 {
// return
// }

// activeTasks, err := tasks.StartScheduledTasks(nil, 50)
// if err != nil {
// log.Err(err).Msg("failed to start scheduled tasks")
// return
// }
// if len(activeTasks) == 0 {
// return
// }

// tasks.DefaultQueue.Process(func(err error) {
// if err != nil {
// log.Err(err).Msg("failed to process tasks")
// return
// }

// // If the queue is now empty, we can run the next batch of tasks right away
// runTasksWorker()

// }, activeTasks...)
}
}

func restartTasksWorker(client core.Client) func() {
return func() {
// _, err := tasks.RestartAbandonedTasks(nil)
// if err != nil {
// log.Err(err).Msg("failed to start scheduled tasks")
// return
// }
}
}
4 changes: 2 additions & 2 deletions cmds/discord/commands/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func init() {
return ctx.Reply(message)
}

account, err := ctx.Core.Fetch.Search(ctx.Context, options.Nickname, options.Server)
account, err := ctx.Core.Fetch().Search(ctx.Context, options.Nickname, options.Server)
if err != nil {
if err.Error() == "no results found" {
return ctx.ReplyFmt("stats_error_nickname_not_fount_fmt", options.Nickname, strings.ToUpper(options.Server))
Expand All @@ -59,7 +59,7 @@ func init() {
currentConnection.Metadata["verified"] = false
currentConnection.ReferenceID = fmt.Sprint(account.ID)

_, err = ctx.Core.DB.UpsertConnection(ctx.Context, currentConnection)
_, err = ctx.Core.Database().UpsertConnection(ctx.Context, currentConnection)
if err != nil {
return ctx.Err(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmds/discord/commands/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
switch {
case options.UserID != "":
// mentioned another user, check if the user has an account linked
mentionedUser, _ := ctx.Core.DB.GetUserByID(ctx.Context, options.UserID, database.WithConnections(), database.WithContent())
mentionedUser, _ := ctx.Core.Database().GetUserByID(ctx.Context, options.UserID, database.WithConnections(), database.WithContent())
defaultAccount, hasDefaultAccount := mentionedUser.Connection(database.ConnectionTypeWargaming)
if !hasDefaultAccount {
return ctx.Reply("stats_error_connection_not_found_vague")
Expand All @@ -40,7 +40,7 @@ func init() {

case options.Nickname != "" && options.Server != "":
// nickname provided and server selected - lookup the account
account, err := ctx.Core.Fetch.Search(ctx.Context, options.Nickname, options.Server)
account, err := ctx.Core.Fetch().Search(ctx.Context, options.Nickname, options.Server)
if err != nil {
if err.Error() == "no results found" {
return ctx.ReplyFmt("stats_error_nickname_not_fount_fmt", options.Nickname, strings.ToUpper(options.Server))
Expand Down
2 changes: 1 addition & 1 deletion cmds/discord/common/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewContext(ctx context.Context, interaction discordgo.Interaction, respondC
return nil, errors.New("failed to get a valid discord user id")
}

user, err := client.DB.GetOrCreateUserByID(ctx, c.Member.ID, database.WithConnections(), database.WithSubscriptions())
user, err := client.Database().GetOrCreateUserByID(ctx, c.Member.ID, database.WithConnections(), database.WithSubscriptions())
if err != nil {
return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/cufee/am-wg-proxy-next/v2 v2.1.2
github.com/disintegration/imaging v1.6.2
github.com/fogleman/gg v1.3.0
github.com/go-co-op/gocron v1.37.0
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/joho/godotenv v1.5.1
github.com/rs/zerolog v1.33.0
Expand All @@ -22,11 +23,14 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
Expand Down
33 changes: 32 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4=
github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cufee/am-wg-proxy-next/v2 v2.1.2 h1:j45xbLPs5FqSsfEccls8AWXK1DIWjnIFEKoiB7M/TGY=
github.com/cufee/am-wg-proxy-next/v2 v2.1.2/go.mod h1:+VxiIdbrdhHdRThASbVmZ5Fz4H6XPCzL3S2Ix6TO/84=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -10,24 +11,43 @@ github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
Expand All @@ -36,7 +56,12 @@ github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+D
github.com/steebchen/prisma-client-go v0.37.0 h1:CYfRxUnIsJRlCvPM4Yw2fElB7Y9rC4f2/PPmHliqyTc=
github.com/steebchen/prisma-client-go v0.37.0/go.mod h1:wp2xU9HO5WIefc65vcl1HOiFUzaHKyOhHw5atrzs8hc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.dedis.ch/fixbuf v1.0.3 h1:hGcV9Cd/znUxlusJ64eAlExS+5cJDIyTyEG+otu5wQs=
Expand All @@ -48,6 +73,8 @@ go.dedis.ch/protobuf v1.0.5/go.mod h1:eIV4wicvi6JK0q/QnfIEGeSFNG0ZeB24kzut5+HaRL
go.dedis.ch/protobuf v1.0.7/go.mod h1:pv5ysfkDX/EawiPqcW3ikOxsL5t+BqnV6xHSmE79KI4=
go.dedis.ch/protobuf v1.0.11 h1:FTYVIEzY/bfl37lu3pR4lIj+F9Vp1jE8oh91VmxKgLo=
go.dedis.ch/protobuf v1.0.11/go.mod h1:97QR256dnkimeNdfmURz0wAMNVbd1VmLXhG1CrTYrJ4=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
Expand All @@ -73,7 +100,11 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6 changes: 3 additions & 3 deletions internal/database/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

type Client interface {
SetVehicleAverages(ctx context.Context, averages map[string]frame.StatsFrame) error
GetVehicleAverages(ctx context.Context, ids []string) (map[string]frame.StatsFrame, error)
UpsertVehicleAverages(ctx context.Context, averages map[string]frame.StatsFrame) error

GetUserByID(ctx context.Context, id string, opts ...userGetOption) (User, error)
GetOrCreateUserByID(ctx context.Context, id string, opts ...userGetOption) (User, error)
Expand All @@ -20,7 +20,7 @@ type Client interface {
// var _ Client = &client{} // just a marker to see if it is implemented correctly

type client struct {
prisma *db.PrismaClient
Raw *db.PrismaClient
}

func NewClient() (*client, error) {
Expand All @@ -30,5 +30,5 @@ func NewClient() (*client, error) {
return nil, err
}

return &client{prisma: prisma}, nil
return &client{Raw: prisma}, nil
}
Loading

0 comments on commit 40b3413

Please sign in to comment.