Skip to content

chore: Remove unused SQL functions #5857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove GetWorkspaceCountByUserID and GetLatestAgentStat
  • Loading branch information
Emyrk committed Jan 25, 2023
commit e853d5fc223bf0043e42f1675d31801e2d85e0a5
27 changes: 0 additions & 27 deletions coderd/database/databasefake/databasefake.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,33 +283,6 @@ func (q *fakeQuerier) InsertAgentStat(_ context.Context, p database.InsertAgentS
return stat, nil
}

func (q *fakeQuerier) GetLatestAgentStat(_ context.Context, agentID uuid.UUID) (database.AgentStat, error) {
q.mutex.RLock()
defer q.mutex.RUnlock()

found := false
latest := database.AgentStat{}
for _, agentStat := range q.agentStats {
if agentStat.AgentID != agentID {
continue
}
if !found {
latest = agentStat
found = true
continue
}
if agentStat.CreatedAt.After(latest.CreatedAt) {
latest = agentStat
found = true
continue
}
}
if !found {
return database.AgentStat{}, sql.ErrNoRows
}
return latest, nil
}

func (q *fakeQuerier) GetTemplateDAUs(_ context.Context, templateID uuid.UUID) ([]database.GetTemplateDAUsRow, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
Expand Down
2 changes: 0 additions & 2 deletions coderd/database/querier.go

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

39 changes: 1 addition & 38 deletions coderd/database/queries.sql.go

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

5 changes: 1 addition & 4 deletions coderd/database/queries/agentstats.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ INSERT INTO
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING *;

-- name: GetLatestAgentStat :one
SELECT * FROM agent_stats WHERE agent_id = $1 ORDER BY created_at DESC LIMIT 1;

-- name: GetTemplateDAUs :many
SELECT
SELECT
(created_at at TIME ZONE 'UTC')::date as date,
user_id
FROM
Expand Down
10 changes: 0 additions & 10 deletions coderd/database/queries/workspaces.sql
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,6 @@ WHERE
GROUP BY
template_id;

-- name: GetWorkspaceCountByUserID :one
SELECT
COUNT(id)
FROM
workspaces
WHERE
owner_id = @owner_id
-- Ignore deleted workspaces
AND deleted != true;

-- name: InsertWorkspace :one
INSERT INTO
workspaces (
Expand Down