Files
flatrender/services/render/internal/db/renders_admin.go
T
soroush.asadi ebf0e11f22
Build backend images / build content-svc (push) Failing after 53s
Build backend images / build file-svc (push) Failing after 55s
Build backend images / build gateway (push) Failing after 58s
Build backend images / build identity-svc (push) Failing after 1m0s
Build backend images / build notification-svc (push) Failing after 49s
Build backend images / build render-svc (push) Failing after 56s
Build backend images / build studio-svc (push) Failing after 59s
fix(render+admin): render queue shows ALL users' jobs
The admin render queue called the user-scoped /v1/renders (so it only showed the
admin's own jobs) and parsed items/total instead of data/meta (→ always empty).
- render-svc: GET /v1/admin-renders (admin) → ListAllJobs across users, optional
  ?status= filter; gateway-wired
- admin renders page now fetches /v1/admin-renders and reads data/meta correctly

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 07:35:17 +03:30

46 lines
1.6 KiB
Go

package db
import (
"context"
"fmt"
"github.com/flatrender/render-svc/internal/models"
)
const jobCols = `id, tenant_id, user_id, saved_project_id, original_project_id,
project_name, title, name, external_job_id, priority_queue::text, priority_score,
step::text, render_progress, convert_progress, image_preview_b64,
price_type::text, paid_price_minor, discount_code, support_flatrender,
mode, quality::text, resolution, r_height, frame_rate, is_60_fps,
duration_sec, export_duration_sec,
has_music, has_sfx, has_voiceover, music_volume, sfx_volume, voiceover_volume,
render_node_count, current_active_nodes, region, tell_me_when_done,
retry_count, max_retries, repair_attempts, failed_message, failed_at_step::text,
export_id, task_start_date, queued_at, started_at, completed_at, created_at, updated_at`
// ListAllJobs returns render jobs across all users (admin view), optional status filter.
func (s *Store) ListAllJobs(ctx context.Context, status string, page, pageSize int) ([]*models.RenderJob, int64, error) {
where := ""
args := []any{}
idx := 1
if status != "" {
where = fmt.Sprintf(" WHERE step::text = $%d", idx)
args = append(args, status)
idx++
}
var total int64
_ = s.pool.QueryRow(ctx, "SELECT COUNT(*) FROM render.render_jobs"+where, args...).Scan(&total)
args = append(args, pageSize, (page-1)*pageSize)
q := "SELECT " + jobCols + " FROM render.render_jobs" + where +
fmt.Sprintf(" ORDER BY created_at DESC LIMIT $%d OFFSET $%d", idx, idx+1)
rows, err := s.pool.Query(ctx, q, args...)
if err != nil {
return nil, 0, err
}
defer rows.Close()
jobs, err := scanJobs(rows)
return jobs, total, err
}