fix(render+admin): render queue shows ALL users' jobs
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
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
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>
This commit is contained in:
@@ -137,6 +137,7 @@ func main() {
|
|||||||
v1.Any("/nodes/*path", apiRL, auth, render.Handler())
|
v1.Any("/nodes/*path", apiRL, auth, render.Handler())
|
||||||
v1.Any("/node-fonts/*path", apiRL, auth, render.Handler())
|
v1.Any("/node-fonts/*path", apiRL, auth, render.Handler())
|
||||||
v1.Any("/admin-exports/*path", apiRL, auth, render.Handler())
|
v1.Any("/admin-exports/*path", apiRL, auth, render.Handler())
|
||||||
|
v1.Any("/admin-renders", apiRL, auth, render.Handler())
|
||||||
v1.Any("/node-updates/*path", apiRL, auth, render.Handler())
|
v1.Any("/node-updates/*path", apiRL, auth, render.Handler())
|
||||||
|
|
||||||
// ── Notification Service ──────────────────────────────────────────────────
|
// ── Notification Service ──────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ func main() {
|
|||||||
nodeFonts.DELETE("/:id", fontH.Delete)
|
nodeFonts.DELETE("/:id", fontH.Delete)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Render queue (admin: all users' jobs) ─────────────────────────────────
|
||||||
|
v1.GET("/admin-renders", auth, admin, renderH.AdminList)
|
||||||
|
|
||||||
// ── Exports management (admin: all users' rendered videos) ────────────────
|
// ── Exports management (admin: all users' rendered videos) ────────────────
|
||||||
adminExports := v1.Group("/admin-exports", auth, admin)
|
adminExports := v1.Group("/admin-exports", auth, admin)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package handlers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/flatrender/render-svc/internal/models"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GET /v1/admin-renders — all users' render jobs (admin), optional ?status= filter.
|
||||||
|
func (h *RenderHandler) AdminList(c *gin.Context) {
|
||||||
|
status := c.Query("status")
|
||||||
|
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
pageSize, _ := strconv.Atoi(c.DefaultQuery("page_size", "30"))
|
||||||
|
if pageSize < 1 || pageSize > 100 {
|
||||||
|
pageSize = 30
|
||||||
|
}
|
||||||
|
jobs, total, err := h.store.ListAllJobs(c.Request.Context(), status, page, pageSize)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, models.APIError{Code: "internal_error", Message: err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if jobs == nil {
|
||||||
|
jobs = []*models.RenderJob{}
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, models.PagedResponse[*models.RenderJob]{
|
||||||
|
Data: jobs,
|
||||||
|
Meta: models.PaginationMeta{Page: page, PageSize: pageSize, Total: total, HasMore: int64(page*pageSize) < total},
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -23,8 +23,8 @@ export type V2RenderJob = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface V2RenderList {
|
interface V2RenderList {
|
||||||
items: V2RenderJob[];
|
data: V2RenderJob[];
|
||||||
total: number;
|
meta?: { total?: number };
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function AdminRendersPage({
|
export default async function AdminRendersPage({
|
||||||
@@ -33,10 +33,11 @@ export default async function AdminRendersPage({
|
|||||||
searchParams: { step?: string };
|
searchParams: { step?: string };
|
||||||
}) {
|
}) {
|
||||||
const step = searchParams.step ?? "";
|
const step = searchParams.step ?? "";
|
||||||
const qs = step ? `?step=${step}&pageSize=50` : "?pageSize=50";
|
// Admin endpoint → all users' jobs (not just the caller's).
|
||||||
const data = await adminGet<V2RenderList>(`/v1/renders${qs}`);
|
const qs = step ? `?status=${step}&page_size=50` : "?page_size=50";
|
||||||
const jobs = data?.items ?? [];
|
const data = await adminGet<V2RenderList>(`/v1/admin-renders${qs}`);
|
||||||
const total = data?.total ?? 0;
|
const jobs = data?.data ?? [];
|
||||||
|
const total = data?.meta?.total ?? 0;
|
||||||
const t = await getTranslations("auto.appAdminRendersPage");
|
const t = await getTranslations("auto.appAdminRendersPage");
|
||||||
|
|
||||||
const steps = ["Queued", "Preparing", "Rendering", "Uploading", "Done", "Failed", "Cancelled"];
|
const steps = ["Queued", "Preparing", "Rendering", "Uploading", "Done", "Failed", "Cancelled"];
|
||||||
|
|||||||
Reference in New Issue
Block a user