feat: finalize academy redesign and production readiness
Align admin, community, search, library, learning and course management with the mockup. Add saved courses, download history, public community feed, instructor directory, backend search, course views, admin content tools and community moderation. Harden API and Nginx for production.
This commit is contained in:
@@ -95,7 +95,7 @@ async function insertAssets(client: PoolClient, parent: { courseId?: string; les
|
||||
|
||||
async function assertActiveCategory(category: string) {
|
||||
const result = await pool.query('select 1 from course_categories where name = $1 and is_active', [category]);
|
||||
if (!result.rowCount) throw new CourseContentConflict('Selecione uma trilha ativa criada pelo superadmin.');
|
||||
if (!result.rowCount) throw new CourseContentConflict('Selecione uma trilha ativa criada pelo admin.');
|
||||
}
|
||||
|
||||
function assertPublishable(input: CourseInput) {
|
||||
@@ -185,8 +185,18 @@ export const manageCourseRoutes: FastifyPluginAsync = async (app) => {
|
||||
const filters = request.user.role === 'admin'
|
||||
? { sql: "where c.status <> 'archived' order by c.created_at desc", values: [] as string[] }
|
||||
: { sql: "where c.instructor_id = $1 and c.status <> 'archived' order by c.created_at desc", values: [request.user.id] };
|
||||
const result = await pool.query(`${courseSelect(false, true)} ${filters.sql}`, filters.values);
|
||||
return { data: result.rows };
|
||||
const withLearners = await pool.query(
|
||||
`select base.*, coalesce((
|
||||
select count(distinct lp.user_id)
|
||||
from lessons l
|
||||
join lesson_progress lp on lp.lesson_id = l.id
|
||||
where l.course_id = base.id
|
||||
), 0)::int as learners
|
||||
from (${courseSelect(false, true)} ${filters.sql}) base
|
||||
order by base."createdAt" desc`,
|
||||
filters.values,
|
||||
);
|
||||
return { data: withLearners.rows };
|
||||
});
|
||||
|
||||
app.get('/analytics', manageAccess, async (request) => {
|
||||
@@ -197,7 +207,10 @@ export const manageCourseRoutes: FastifyPluginAsync = async (app) => {
|
||||
count(distinct l.id)::int as "lessons",
|
||||
count(distinct lp.user_id)::int as "learners",
|
||||
count(distinct lp.lesson_id) filter (where lp.completed_at is not null)::int as "completedLessons",
|
||||
count(distinct cm.id)::int as "comments"
|
||||
count(distinct cm.id)::int as "comments",
|
||||
count(distinct cm.id) filter (where not exists (
|
||||
select 1 from comment_replies cr where cr.comment_id = cm.id
|
||||
))::int as "unansweredComments"
|
||||
from courses c
|
||||
left join lessons l on l.course_id = c.id
|
||||
left join lesson_progress lp on lp.lesson_id = l.id
|
||||
|
||||
Reference in New Issue
Block a user