Chore: actions methods rename
This commit is contained in:
		| @@ -8,14 +8,14 @@ import ( | ||||
| ) | ||||
|  | ||||
| type ActionsRepo interface { | ||||
| 	ListActions(ctx context.Context, roomID string) ([]models.Action, error) | ||||
| 	CreateAction(ctx context.Context, action *models.Action) error | ||||
| 	GetLastClue(ctx context.Context, roomID string) (*models.Action, error) | ||||
| 	DeleteActionsByRoomID(ctx context.Context, roomID string) error | ||||
| 	ActionsDeleteOrphaned(ctx context.Context) error | ||||
| 	ActionList(ctx context.Context, roomID string) ([]models.Action, error) | ||||
| 	ActionCreate(ctx context.Context, action *models.Action) error | ||||
| 	ActionGetLastClue(ctx context.Context, roomID string) (*models.Action, error) | ||||
| 	ActionDeleteByRoomID(ctx context.Context, roomID string) error | ||||
| 	ActionDeleteOrphaned(ctx context.Context) error | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) ListActions(ctx context.Context, roomID string) ([]models.Action, error) { | ||||
| func (p *RepoProvider) ActionList(ctx context.Context, roomID string) ([]models.Action, error) { | ||||
| 	actions := []models.Action{} | ||||
| 	err := sqlx.SelectContext(ctx, p.DB, &actions, `SELECT actor, actor_color, action_type, word, word_color, number_associated, created_at FROM actions WHERE room_id = ? ORDER BY created_at ASC`, roomID) | ||||
| 	if err != nil { | ||||
| @@ -24,13 +24,13 @@ func (p *RepoProvider) ListActions(ctx context.Context, roomID string) ([]models | ||||
| 	return actions, nil | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) CreateAction(ctx context.Context, a *models.Action) error { | ||||
| func (p *RepoProvider) ActionCreate(ctx context.Context, a *models.Action) error { | ||||
| 	db := getDB(ctx, p.DB) | ||||
| 	_, err := db.ExecContext(ctx, `INSERT INTO actions (room_id, actor, actor_color, action_type, word, word_color, number_associated, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, a.RoomID, a.Actor, a.ActorColor, a.Action, a.Word, a.WordColor, a.Number, a.CreatedAt.UnixNano()) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) GetLastClue(ctx context.Context, roomID string) (*models.Action, error) { | ||||
| func (p *RepoProvider) ActionGetLastClue(ctx context.Context, roomID string) (*models.Action, error) { | ||||
| 	action := &models.Action{} | ||||
| 	err := sqlx.GetContext(ctx, p.DB, action, `SELECT actor, actor_color, action_type, word, word_color, number_associated, created_at FROM actions WHERE room_id = ? AND action_type = 'gave_clue' ORDER BY created_at DESC LIMIT 1`, roomID) | ||||
| 	if err != nil { | ||||
| @@ -39,13 +39,13 @@ func (p *RepoProvider) GetLastClue(ctx context.Context, roomID string) (*models. | ||||
| 	return action, nil | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) DeleteActionsByRoomID(ctx context.Context, roomID string) error { | ||||
| func (p *RepoProvider) ActionDeleteByRoomID(ctx context.Context, roomID string) error { | ||||
| 	db := getDB(ctx, p.DB) | ||||
| 	_, err := db.ExecContext(ctx, `DELETE FROM actions WHERE room_id = ?`, roomID) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func (p *RepoProvider) ActionsDeleteOrphaned(ctx context.Context) error { | ||||
| func (p *RepoProvider) ActionDeleteOrphaned(ctx context.Context) error { | ||||
| 	db := getDB(ctx, p.DB) | ||||
| 	_, err := db.ExecContext(ctx, `DELETE FROM actions WHERE room_id NOT IN (SELECT id FROM rooms)`) | ||||
| 	return err | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder