Address follow-up review: cheaper avatars, list limits, less chatter.
Switch avatar resize to ApproxBiLinear, cap hunt/profile/admin list queries, drop redundant admin/profile lookups, dedupe CI on app PRs, and refresh stale todo.md notes.
This commit is contained in:
@@ -117,11 +117,13 @@ LEFT JOIN answers a ON a.question_id = q.id
|
||||
WHERE q.hunt_date = $2 AND q.hidden = 0
|
||||
GROUP BY q.id, q.author_id, u.name, q.title, q.body, q.city, q.hunt_date, q.hidden, q.created_at, a.question_id
|
||||
ORDER BY score DESC, q.created_at ASC
|
||||
LIMIT $3
|
||||
`
|
||||
|
||||
type ListHuntParams struct {
|
||||
ViewerID string
|
||||
HuntDate string
|
||||
RowLimit int32
|
||||
}
|
||||
|
||||
type ListHuntRow struct {
|
||||
@@ -140,7 +142,7 @@ type ListHuntRow struct {
|
||||
}
|
||||
|
||||
func (q *Queries) ListHunt(ctx context.Context, arg ListHuntParams) ([]ListHuntRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listHunt, arg.ViewerID, arg.HuntDate)
|
||||
rows, err := q.db.QueryContext(ctx, listHunt, arg.ViewerID, arg.HuntDate, arg.RowLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -185,8 +187,14 @@ JOIN questions q ON q.id = ans.question_id
|
||||
JOIN users u ON u.id = q.author_id
|
||||
WHERE ans.author_id = $1 AND q.hidden = 0
|
||||
ORDER BY ans.updated_at DESC
|
||||
LIMIT $2
|
||||
`
|
||||
|
||||
type ListQuestionsAnsweredByParams struct {
|
||||
AdminID string
|
||||
RowLimit int32
|
||||
}
|
||||
|
||||
type ListQuestionsAnsweredByRow struct {
|
||||
ID string
|
||||
AuthorID string
|
||||
@@ -202,8 +210,8 @@ type ListQuestionsAnsweredByRow struct {
|
||||
UserVote int64
|
||||
}
|
||||
|
||||
func (q *Queries) ListQuestionsAnsweredBy(ctx context.Context, adminID string) ([]ListQuestionsAnsweredByRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listQuestionsAnsweredBy, adminID)
|
||||
func (q *Queries) ListQuestionsAnsweredBy(ctx context.Context, arg ListQuestionsAnsweredByParams) ([]ListQuestionsAnsweredByRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listQuestionsAnsweredBy, arg.AdminID, arg.RowLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -248,8 +256,14 @@ JOIN users u ON u.id = q.author_id
|
||||
LEFT JOIN answers a ON a.question_id = q.id
|
||||
WHERE q.author_id = $1 AND q.hidden = 0
|
||||
ORDER BY q.created_at DESC
|
||||
LIMIT $2
|
||||
`
|
||||
|
||||
type ListQuestionsByAuthorParams struct {
|
||||
AuthorID string
|
||||
RowLimit int32
|
||||
}
|
||||
|
||||
type ListQuestionsByAuthorRow struct {
|
||||
ID string
|
||||
AuthorID string
|
||||
@@ -265,8 +279,8 @@ type ListQuestionsByAuthorRow struct {
|
||||
UserVote int64
|
||||
}
|
||||
|
||||
func (q *Queries) ListQuestionsByAuthor(ctx context.Context, authorID string) ([]ListQuestionsByAuthorRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listQuestionsByAuthor, authorID)
|
||||
func (q *Queries) ListQuestionsByAuthor(ctx context.Context, arg ListQuestionsByAuthorParams) ([]ListQuestionsByAuthorRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listQuestionsByAuthor, arg.AuthorID, arg.RowLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ const listUsers = `-- name: ListUsers :many
|
||||
SELECT id, username, name, role, avatar_url, state, created_at
|
||||
FROM users
|
||||
ORDER BY created_at ASC
|
||||
LIMIT $1
|
||||
`
|
||||
|
||||
type ListUsersRow struct {
|
||||
@@ -142,8 +143,8 @@ type ListUsersRow struct {
|
||||
CreatedAt string
|
||||
}
|
||||
|
||||
func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listUsers)
|
||||
func (q *Queries) ListUsers(ctx context.Context, rowLimit int32) ([]ListUsersRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listUsers, rowLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user