woogles-io / liwords

A site that allows people to play a crossword board game against each other
https://woogles.io
GNU Affero General Public License v3.0
84 stars 14 forks source link

Consolidate Stores #632

Closed jvc56 closed 4 months ago

jvc56 commented 3 years ago

We should weto this:

return gameplay.TimedOut(ctx, b.gameStore, b.userStore, b.notorietyStore, b.listStatStore, b.tournamentStore, evt.UserId, evt.GameId)

And replace it with something like this:

return gameplay.TimedOut(ctx, gameplayStores, evt.UserId, evt.GameId)

In all places where the stores are getting out of hand.

andy-k commented 3 years ago

stores are getting out of hand, but consolidating them into a struct doesn't solve the problems they're causing.

but i don't have a good solution to this that doesn't essentially amount to a full rewrite.

domino14 commented 3 years ago

These started as different stores because we didn't even add Postgres until several months after we started the project. We used to store games in memory, users were all anonymous, etc. Once we started adding persistence we started creating db stores gradually (while some things remained in memory until much later, like SoughtGame, some things moved to Redis..)

Some possible solutions:

andy-k commented 3 years ago
jvc56 commented 3 years ago

This is blocking the migration of action histories, which just adds more tech debt to this problem. I think we should make this a more urgent priority, even if that amounts to a complete rewrite.

domino14 commented 3 years ago

There is a

type Stores struct {
    UserStore       user.Store
    GameStore       gameplay.GameStore
    SoughtGameStore gameplay.SoughtGameStore
    PresenceStore   user.PresenceStore
    ChatStore       user.ChatStore
    ListStatStore   stats.ListStatStore
    NotorietyStore  mod.NotorietyStore
    TournamentStore tournament.TournamentStore
    ConfigStore     config.ConfigStore
    SessionStore    sessions.SessionStore
}

in bus.go that gets passed around a few places. Can we add whatever you need there and pass it to more places? If we do that though, I may want to pass a pointer around.