Skip to content

Commit

Permalink
fix(api-gql): correctly create default rows for games
Browse files Browse the repository at this point in the history
  • Loading branch information
Satont committed May 2, 2024
1 parent c733efb commit 6c33e2f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
20 changes: 4 additions & 16 deletions apps/api-gql/internal/gql/resolvers/games.resolver.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/api-gql/internal/gql/resolvers/games.resolver.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"

"github.com/lib/pq"
model "github.com/satont/twir/libs/gomodels"
"github.com/twirapp/twir/apps/api-gql/internal/gql/gqlmodel"
)
Expand All @@ -16,6 +17,8 @@ func (r *queryResolver) gamesGetEightBall(ctx context.Context) (*gqlmodel.EightB

entity := model.ChannelGames8Ball{
ChannelId: dashboardId,
Enabled: false,
Answers: pq.StringArray{},
}
if err := r.gorm.
WithContext(ctx).
Expand Down
3 changes: 2 additions & 1 deletion libs/gomodels/channel_games_8ball.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package model

import (
"github.com/google/uuid"
"github.com/lib/pq"
)

type ChannelGames8Ball struct {
ID string `gorm:"column:id;type:uuid" json:"id"`
ID uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid()" json:"id"`
ChannelId string `gorm:"column:channel_id;type:text" json:"channelId"`
Enabled bool `gorm:"column:enabled" json:"enabled"`
Answers pq.StringArray `gorm:"column:answers;type:text[]" json:"answers"`
Expand Down
30 changes: 17 additions & 13 deletions libs/gomodels/channel_games_duel.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package model

import (
"github.com/google/uuid"
)

type ChannelGamesDuel struct {
ID string `gorm:"column:id;type:uuid"`
ChannelID string `gorm:"column:channel_id;type:text"`
Enabled bool `gorm:"column:enabled;type:bool"`
UserCooldown int32 `gorm:"column:user_cooldown;type:int"`
GlobalCooldown int32 `gorm:"column:global_cooldown;type:int"`
TimeoutSeconds int32 `gorm:"column:timeout_seconds;type:int"`
StartMessage string `gorm:"column:start_message;type:text"`
ResultMessage string `gorm:"column:result_message;type:text"`
SecondsToAccept int32 `gorm:"column:seconds_to_accept;type:int"`
PointsPerWin int32 `gorm:"column:points_per_win;type:int"`
PointsPerLose int32 `gorm:"column:points_per_lose;type:int"`
BothDiePercent int32 `gorm:"column:both_die_percent;type:int"`
BothDieMessage string `gorm:"column:both_die_message;type:text"`
ID uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid()"`
ChannelID string `gorm:"column:channel_id;type:text"`
Enabled bool `gorm:"column:enabled;type:bool"`
UserCooldown int32 `gorm:"column:user_cooldown;type:int"`
GlobalCooldown int32 `gorm:"column:global_cooldown;type:int"`
TimeoutSeconds int32 `gorm:"column:timeout_seconds;type:int"`
StartMessage string `gorm:"column:start_message;type:text"`
ResultMessage string `gorm:"column:result_message;type:text"`
SecondsToAccept int32 `gorm:"column:seconds_to_accept;type:int"`
PointsPerWin int32 `gorm:"column:points_per_win;type:int"`
PointsPerLose int32 `gorm:"column:points_per_lose;type:int"`
BothDiePercent int32 `gorm:"column:both_die_percent;type:int"`
BothDieMessage string `gorm:"column:both_die_message;type:text"`
}

func (c ChannelGamesDuel) TableName() string {
Expand Down
22 changes: 13 additions & 9 deletions libs/gomodels/channel_games_russian_roulette.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package model

import (
"github.com/google/uuid"
)

type ChannelGamesRussianRoulette struct {
ID string `gorm:"column:id;type:uuid"`
ChannelID string `gorm:"column:channel_id;type:text"`
Enabled bool `gorm:"column:enabled;type:bool" json:"enabled"`
CanBeUsedByModerators bool `gorm:"column:can_be_used_by_moderator;type:bool" json:"canBeUsedByModerator"`
TimeoutSeconds int `gorm:"column:timeout_seconds;type:int" json:"timeoutTime"`
DecisionSeconds int `gorm:"column:decision_time;type:int" json:"decisionTime"`
TumberSize int `gorm:"column:tumber_size;type:int" json:"tumberSize"`
ChargedBullets int `gorm:"column:charged_bullets;type:int" json:"chargedBullets"`
ID uuid.UUID `gorm:"column:id;type:uuid;default:gen_random_uuid()"`
ChannelID string `gorm:"column:channel_id;type:text"`
Enabled bool `gorm:"column:enabled;type:bool" json:"enabled"`
CanBeUsedByModerators bool `gorm:"column:can_be_used_by_moderators;type:bool" json:"canBeUsedByModerator"`
TimeoutSeconds int `gorm:"column:timeout_seconds;type:int" json:"timeoutSeconds"`
DecisionSeconds int `gorm:"column:decision_seconds;type:int" json:"decisionSeconds"`
TumberSize int `gorm:"column:tumber_size;type:int" json:"tumberSize"`
ChargedBullets int `gorm:"column:charged_bullets;type:int" json:"chargedBullets"`

InitMessage string `gorm:"column:init_messages;type:text" json:"initMessage"`
InitMessage string `gorm:"column:init_message;type:text" json:"initMessage"`
SurviveMessage string `gorm:"column:survive_message;type:text" json:"surviveMessage"`
DeathMessage string `gorm:"column:death_message;type:text" json:"deathMessage"`
}
Expand Down

0 comments on commit 6c33e2f

Please sign in to comment.