fix names

This commit is contained in:
2026-10-01 13:13:03 +07:00
parent 76af14cb96
commit f462bc6a03
24 changed files with 213 additions and 213 deletions
+9 -9
View File
@@ -26,7 +26,7 @@ func NewActionsRepo(pool *pgxpool.Pool) *ActionsRepo {
}
}
func (r *ActionsRepo) AddAction(ctx context.Context, teamId int, code string, viaMCP bool) (int, error) {
func (r *ActionsRepo) AddAction(ctx context.Context, teamID int, code string, viaMCP bool) (int, error) {
id := 0
err := r.pool.QueryRow(
ctx,
@@ -34,7 +34,7 @@ func (r *ActionsRepo) AddAction(ctx context.Context, teamId int, code string, vi
VALUES ($1, $2, $3)
RETURNING id`,
code,
teamId,
teamID,
viaMCP,
).Scan(&id)
@@ -44,7 +44,7 @@ func (r *ActionsRepo) AddAction(ctx context.Context, teamId int, code string, vi
return id, nil
}
func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamId int) ([]Action, error) {
func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamID int) ([]Action, error) {
rows, err := r.pool.Query(
ctx,
`SELECT
@@ -53,7 +53,7 @@ func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamId int) ([]Act
FROM actions
WHERE team_id = $1
ORDER BY created_at ASC`,
teamId,
teamID,
)
if err != nil {
return nil, err
@@ -79,7 +79,7 @@ func (r *ActionsRepo) GetActionsByTeamID(ctx context.Context, teamId int) ([]Act
return actions, nil
}
func (r *ActionsRepo) GetActionsCountByTeamIDs(ctx context.Context, teamIds []int) (map[int]int, error) {
func (r *ActionsRepo) GetActionsCountByTeamIDs(ctx context.Context, teamIDs []int) (map[int]int, error) {
rows, err := r.pool.Query(
ctx,
`SELECT
@@ -88,14 +88,14 @@ func (r *ActionsRepo) GetActionsCountByTeamIDs(ctx context.Context, teamIds []in
FROM actions
WHERE team_id = ANY($1)
GROUP BY team_id`,
teamIds,
teamIDs,
)
if err != nil {
return nil, err
}
defer rows.Close()
res := make(map[int]int, len(teamIds))
res := make(map[int]int, len(teamIDs))
for rows.Next() {
id := 0
count := 0
@@ -115,7 +115,7 @@ func (r *ActionsRepo) GetActionsCountByTeamIDs(ctx context.Context, teamIds []in
return res, nil
}
func (r *ActionsRepo) DeleteLastActionByTeamId(ctx context.Context, teamId int) error {
func (r *ActionsRepo) DeleteLastActionByTeamID(ctx context.Context, teamID int) error {
tag, err := r.pool.Exec(
ctx,
`DELETE FROM actions
@@ -126,7 +126,7 @@ func (r *ActionsRepo) DeleteLastActionByTeamId(ctx context.Context, teamId int)
ORDER BY created_at DESC
LIMIT 1
)`,
teamId,
teamID,
)
if err != nil {
return err
+1 -1
View File
@@ -3,7 +3,7 @@ package repos
// TeamAnswer — ответ команды на вопрос дела (вопросы живут в сценарии,
// ответы — в таблице team_answers).
type TeamAnswer struct {
TeamId int
TeamID int
QuestionCode string
Text string
// Score — балл, выставленный организатором; nil — ещё не оценено.
+1 -1
View File
@@ -3,6 +3,6 @@ package repos
type Application struct {
Name string
Image string
TeamId int
TeamID int
FileType string
}
+11 -11
View File
@@ -24,7 +24,7 @@ func NewApplicationsRepo(pool *pgxpool.Pool) *ApplicationsRepo {
func (r *ApplicationsRepo) AddApplication(
ctx context.Context,
teamId int,
teamID int,
name string,
image string,
fileType string,
@@ -38,7 +38,7 @@ func (r *ApplicationsRepo) AddApplication(
name,
image,
fileType,
teamId,
teamID,
).Scan(&id)
if err != nil {
@@ -49,7 +49,7 @@ func (r *ApplicationsRepo) AddApplication(
func (r *ApplicationsRepo) GetApplicationsByTeamIDsAndState(
ctx context.Context,
teamIds []int,
teamIDs []int,
state string,
) (map[int][]*repos.Application, error) {
rows, err := r.pool.Query(
@@ -61,7 +61,7 @@ func (r *ApplicationsRepo) GetApplicationsByTeamIDsAndState(
team_id
FROM applications
WHERE team_id = ANY($1) and status = $2`,
teamIds,
teamIDs,
state,
)
if err != nil {
@@ -69,19 +69,19 @@ func (r *ApplicationsRepo) GetApplicationsByTeamIDsAndState(
}
defer rows.Close()
res := make(map[int][]*repos.Application, len(teamIds))
res := make(map[int][]*repos.Application, len(teamIDs))
for rows.Next() {
application := &repos.Application{}
err := rows.Scan(
&application.Name,
&application.Image,
&application.FileType,
&application.TeamId,
&application.TeamID,
)
if err != nil {
return nil, err
}
res[application.TeamId] = append(res[application.TeamId], application)
res[application.TeamID] = append(res[application.TeamID], application)
}
if err := rows.Err(); err != nil {
return nil, err
@@ -92,7 +92,7 @@ func (r *ApplicationsRepo) GetApplicationsByTeamIDsAndState(
func (r *ApplicationsRepo) UpdateApplicationStatus(
ctx context.Context,
teamId int,
teamID int,
name string,
status string,
) error {
@@ -103,7 +103,7 @@ func (r *ApplicationsRepo) UpdateApplicationStatus(
status = $1
WHERE team_id = $2 and name = $3`,
status,
teamId,
teamID,
name,
)
if err != nil {
@@ -115,7 +115,7 @@ func (r *ApplicationsRepo) UpdateApplicationStatus(
return nil
}
func (r *ApplicationsRepo) DeleteApplicationByTeamIdAndName(ctx context.Context, teamId int, name string) error {
func (r *ApplicationsRepo) DeleteApplicationByTeamIDAndName(ctx context.Context, teamID int, name string) error {
tag, err := r.pool.Exec(
ctx,
`DELETE FROM applications
@@ -126,7 +126,7 @@ func (r *ApplicationsRepo) DeleteApplicationByTeamIdAndName(ctx context.Context,
ORDER BY created_at DESC
LIMIT 1
)`,
teamId,
teamID,
name,
)
if err != nil {
+1 -1
View File
@@ -12,7 +12,7 @@ type Game struct {
Location *string
StartAt time.Time
Status string
ScenarioId int
ScenarioID int
Scenario *Scenario
Teams []*Team
StartedAt *time.Time
+5 -5
View File
@@ -30,7 +30,7 @@ func (r *GamesRepo) AddGame(
description string,
location *string,
startAt time.Time,
scenarioId int32,
scenarioID int32,
format string,
) (int, error) {
id := 0
@@ -43,7 +43,7 @@ func (r *GamesRepo) AddGame(
description,
location,
startAt,
scenarioId,
scenarioID,
format,
).Scan(&id)
@@ -83,7 +83,7 @@ func (r *GamesRepo) GetGameByID(
&game.StartAt,
&game.Format,
&game.Status,
&game.ScenarioId,
&game.ScenarioID,
&game.StartedAt,
&game.EndedAt,
)
@@ -168,7 +168,7 @@ func (r *GamesRepo) UpdateGame(
description string,
location *string,
startAt time.Time,
scenarioId int32,
scenarioID int32,
format string,
) error {
tag, err := r.pool.Exec(
@@ -187,7 +187,7 @@ func (r *GamesRepo) UpdateGame(
description,
location,
startAt,
scenarioId,
scenarioID,
format,
id,
)
+4 -4
View File
@@ -19,7 +19,7 @@ func NewRefreshTokensRepo(pool *pgxpool.Pool) *RefreshTokensRepo {
func (s *RefreshTokensRepo) AddRefreshToken(
ctx context.Context,
userId int,
userID int,
expiresAt time.Time,
jti string,
) error {
@@ -27,7 +27,7 @@ func (s *RefreshTokensRepo) AddRefreshToken(
ctx,
`INSERT INTO refresh_tokens (user_id, expires_at, jti)
VALUES ($1, $2, $3)`,
userId,
userID,
expiresAt,
jti,
)
@@ -36,7 +36,7 @@ func (s *RefreshTokensRepo) AddRefreshToken(
func (s *RefreshTokensRepo) ExistsRefreshToken(
ctx context.Context,
userId int,
userID int,
jti string,
now time.Time,
) (bool, error) {
@@ -51,7 +51,7 @@ func (s *RefreshTokensRepo) ExistsRefreshToken(
AND jti = $2
AND expires_at > $3
)`,
userId,
userID,
jti,
now,
).Scan(&exists)
+4 -4
View File
@@ -26,7 +26,7 @@ func NewScenariosRepo(pool *pgxpool.Pool) *ScenariosRepo {
func (r *ScenariosRepo) AddScenario(
ctx context.Context,
name string,
authorId int,
authorID int,
) (int, error) {
id := 0
err := r.pool.QueryRow(
@@ -35,7 +35,7 @@ func (r *ScenariosRepo) AddScenario(
VALUES ($1, $2)
RETURNING id`,
name,
authorId,
authorID,
).Scan(&id)
if err != nil {
@@ -46,7 +46,7 @@ func (r *ScenariosRepo) AddScenario(
func (r *ScenariosRepo) GetScenariosByAuthorID(
ctx context.Context,
authorId int,
authorID int,
) ([]*repos.Scenario, error) {
rows, err := r.pool.Query(
ctx,
@@ -66,7 +66,7 @@ func (r *ScenariosRepo) GetScenariosByAuthorID(
LEFT JOIN users on scenarios.author_id = users.id
WHERE scenarios.author_id = $1 and is_deleted = FALSE
ORDER BY created_at DESC`,
authorId,
authorID,
)
if err != nil {
return nil, err
+1 -1
View File
@@ -11,5 +11,5 @@ type Team struct {
Name string
Status string
Password string
GameId int
GameID int
}
+10 -10
View File
@@ -21,7 +21,7 @@ func NewTeamAnswersRepo(pool *pgxpool.Pool) *TeamAnswersRepo {
// отсутствующие — вставляются (UNIQUE (team_id, question_code)).
func (r *TeamAnswersRepo) UpsertAnswers(
ctx context.Context,
teamId int,
teamID int,
answers []repos.TeamAnswer,
) error {
for _, answer := range answers {
@@ -33,7 +33,7 @@ func (r *TeamAnswersRepo) UpsertAnswers(
DO UPDATE SET
answer = EXCLUDED.answer,
updated_at = NOW()`,
teamId,
teamID,
answer.QuestionCode,
answer.Text,
)
@@ -46,7 +46,7 @@ func (r *TeamAnswersRepo) UpsertAnswers(
func (r *TeamAnswersRepo) GetAnswersByTeamID(
ctx context.Context,
teamId int,
teamID int,
) ([]*repos.TeamAnswer, error) {
rows, err := r.pool.Query(
ctx,
@@ -58,7 +58,7 @@ func (r *TeamAnswersRepo) GetAnswersByTeamID(
FROM team_answers
WHERE team_id = $1
ORDER BY question_code ASC`,
teamId,
teamID,
)
if err != nil {
return nil, err
@@ -69,7 +69,7 @@ func (r *TeamAnswersRepo) GetAnswersByTeamID(
for rows.Next() {
answer := &repos.TeamAnswer{}
err := rows.Scan(
&answer.TeamId,
&answer.TeamID,
&answer.QuestionCode,
&answer.Text,
&answer.Score,
@@ -89,7 +89,7 @@ func (r *TeamAnswersRepo) GetAnswersByTeamID(
// GetAnswersByGameID возвращает ответы всех команд игры (вместе с баллами).
func (r *TeamAnswersRepo) GetAnswersByGameID(
ctx context.Context,
gameId int,
gameID int,
) ([]*repos.TeamAnswer, error) {
rows, err := r.pool.Query(
ctx,
@@ -102,7 +102,7 @@ func (r *TeamAnswersRepo) GetAnswersByGameID(
JOIN teams ON teams.id = team_answers.team_id
WHERE teams.game_id = $1
ORDER BY teams.id ASC, team_answers.question_code ASC`,
gameId,
gameID,
)
if err != nil {
return nil, err
@@ -113,7 +113,7 @@ func (r *TeamAnswersRepo) GetAnswersByGameID(
for rows.Next() {
answer := &repos.TeamAnswer{}
err := rows.Scan(
&answer.TeamId,
&answer.TeamID,
&answer.QuestionCode,
&answer.Text,
&answer.Score,
@@ -136,7 +136,7 @@ func (r *TeamAnswersRepo) GetAnswersByGameID(
// пустым ответом и выставленным баллом.
func (r *TeamAnswersRepo) SetAnswerScore(
ctx context.Context,
teamId int,
teamID int,
questionCode string,
score *int,
) error {
@@ -148,7 +148,7 @@ func (r *TeamAnswersRepo) SetAnswerScore(
DO UPDATE SET
score = EXCLUDED.score,
updated_at = NOW()`,
teamId,
teamID,
questionCode,
score,
)
+13 -13
View File
@@ -48,7 +48,7 @@ func (r *TeamsRepo) GetTeamByID(ctx context.Context, id int) (*repos.Team, error
&team.ParticipationStatus, &team.ParticipationSource, &team.ParticipationEmailError, &team.ParticipationEmailSent,
&team.Status,
&team.Password,
&team.GameId,
&team.GameID,
)
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
@@ -62,7 +62,7 @@ func (r *TeamsRepo) GetTeamByID(ctx context.Context, id int) (*repos.Team, error
func (r *TeamsRepo) GetTeamsByGameID(
ctx context.Context,
gameId int,
gameID int,
) ([]*repos.Team, error) {
rows, err := r.pool.Query(
ctx,
@@ -77,7 +77,7 @@ func (r *TeamsRepo) GetTeamsByGameID(
FROM teams
WHERE game_id = $1
ORDER BY created_at DESC`,
gameId,
gameID,
)
if err != nil {
return nil, err
@@ -110,15 +110,15 @@ func (r *TeamsRepo) GetTeamsByGameID(
func (r *TeamsRepo) AddTeam(
ctx context.Context,
creatorId int,
gameId int,
creatorID int,
gameID int,
name string,
password string,
) (int, error) {
return r.AddTeamWithParticipation(ctx, creatorId, gameId, name, password, "", false)
return r.AddTeamWithParticipation(ctx, creatorID, gameID, name, password, "", false)
}
func (r *TeamsRepo) AddTeamWithParticipation(ctx context.Context, creatorId, gameId int, name, password, captainEmail string, autoConfirm bool) (int, error) {
func (r *TeamsRepo) AddTeamWithParticipation(ctx context.Context, creatorID, gameID int, name, password, captainEmail string, autoConfirm bool) (int, error) {
id := 0
status, source := "pending", ""
if autoConfirm {
@@ -130,8 +130,8 @@ func (r *TeamsRepo) AddTeamWithParticipation(ctx context.Context, creatorId, gam
VALUES ($1, $2, $3, $4, $5, $6, CASE WHEN $5 = 'confirmed' THEN NOW() ELSE NULL END, $7)
RETURNING id`,
name,
creatorId,
gameId,
creatorID,
gameID,
password,
status,
source,
@@ -144,7 +144,7 @@ func (r *TeamsRepo) AddTeamWithParticipation(ctx context.Context, creatorId, gam
return id, nil
}
func (r *TeamsRepo) UpdateTeam(ctx context.Context, teamId int, name string) error {
func (r *TeamsRepo) UpdateTeam(ctx context.Context, teamID int, name string) error {
tag, err := r.pool.Exec(
ctx,
`UPDATE teams
@@ -152,7 +152,7 @@ func (r *TeamsRepo) UpdateTeam(ctx context.Context, teamId int, name string) err
name = $1
WHERE id = $2`,
name,
teamId,
teamID,
)
if err != nil {
return err
@@ -163,12 +163,12 @@ func (r *TeamsRepo) UpdateTeam(ctx context.Context, teamId int, name string) err
return nil
}
func (r *TeamsRepo) DeleteTeam(ctx context.Context, teamId int) error {
func (r *TeamsRepo) DeleteTeam(ctx context.Context, teamID int) error {
tag, err := r.pool.Exec(
ctx,
`DELETE FROM teams
WHERE id = $1`,
teamId,
teamID,
)
if err != nil {
return err
+8 -8
View File
@@ -226,7 +226,7 @@ func (s *UsersRepo) GetUsers(
func (s *UsersRepo) AddUserRole(
ctx context.Context,
userId int,
userID int,
role string,
) error {
_, err := s.pool.Exec(
@@ -235,14 +235,14 @@ func (s *UsersRepo) AddUserRole(
SET roles = roles || $1::jsonb
WHERE id = $2 AND NOT roles @> $1::jsonb`,
fmt.Sprintf(`["%s"]`, role),
userId,
userID,
)
return err
}
func (s *UsersRepo) DeleteUserRole(
ctx context.Context,
userId int,
userID int,
role string,
) error {
_, err := s.pool.Exec(
@@ -251,7 +251,7 @@ func (s *UsersRepo) DeleteUserRole(
SET roles = roles - $1::text
WHERE id = $2`,
role,
userId,
userID,
)
return err
}
@@ -264,7 +264,7 @@ func (s *UsersRepo) DeleteUserRole(
// контент остаётся в обезличенном виде.
func (s *UsersRepo) DeleteUser(
ctx context.Context,
userId int,
userID int,
) error {
tx, err := s.pool.Begin(ctx)
if err != nil {
@@ -276,7 +276,7 @@ func (s *UsersRepo) DeleteUser(
if _, err = tx.Exec(
ctx,
`DELETE FROM refresh_tokens WHERE user_id = $1`,
userId,
userID,
); err != nil {
return err
}
@@ -293,7 +293,7 @@ func (s *UsersRepo) DeleteUser(
`UPDATE user_agreements
SET user_id = NULL, ip = NULL, user_agent = NULL
WHERE user_id = $1`,
userId,
userID,
); err != nil {
return err
}
@@ -303,7 +303,7 @@ func (s *UsersRepo) DeleteUser(
tag, err := tx.Exec(
ctx,
`DELETE FROM users WHERE id = $1`,
userId,
userID,
)
if err != nil {
return err