feat: add managed learning paths
All checks were successful
CI / Validate frontend and API (push) Successful in 41s
CI / Build and publish Docker images (push) Successful in 23s

This commit is contained in:
Cauê Faleiros
2026-09-04 16:22:09 -03:00
parent e18bb76630
commit 79d1c70c44
9 changed files with 358 additions and 337 deletions

View File

@@ -148,6 +148,34 @@ export const courseRoutes: FastifyPluginAsync = async (app) => {
return { data: authenticated ? result.rows : result.rows.map(withoutProtectedMedia) };
});
// Paths intentionally reference existing courses instead of copying them.
// Only a path and its published courses are visible to visitors.
app.get('/paths', async () => {
const result = await pool.query(
`select
p.id, p.title, p.description,
coalesce(p.cover_image_url, (
select value #>> '{}' from platform_settings where key = 'media.defaultCoverImageUrl'
)) as "coverImageUrl",
p.cover_image_zoom as "coverImageZoom",
p.cover_image_position_x as "coverImagePositionX",
p.cover_image_position_y as "coverImagePositionY",
coalesce(jsonb_agg(jsonb_build_object(
'id', c.id, 'title', c.title, 'category', c.category,
'coverImageUrl', coalesce(c.cover_image_url, (
select value #>> '{}' from platform_settings where key = 'media.defaultCoverImageUrl'
)), 'position', pc.position
) order by pc.position) filter (where c.id is not null), '[]'::jsonb) as courses
from learning_paths p
join learning_path_courses pc on pc.learning_path_id = p.id
join courses c on c.id = pc.course_id and c.status = 'published'
where p.status = 'published'
group by p.id
order by p.published_at desc`,
);
return { data: result.rows };
});
app.get('/me/learning', { preHandler: app.authenticate }, async (request) => {
const result = await pool.query(
`select base.*, coalesce(progress.progress, 0)::int as progress, progress."lastActivity"