mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
chore: relocate backend into apps/api ahead of monorepo merge
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/***********************************************************************************************************************************************************************
|
||||
* File Name: tier_plans.attributes.js
|
||||
* Type of Program: Attributes
|
||||
* Description: Exclude list, display attributes, and computed fields for tier_plans.
|
||||
* Author: Kenneth Obsequio (@lash0000)
|
||||
* Date Created: Jun. 6, 2026
|
||||
***********************************************************************************************************************************************************************/
|
||||
|
||||
const excludeAttributes = [
|
||||
"tier_category_id",
|
||||
"description",
|
||||
];
|
||||
|
||||
const jsonbSchemas = {}; // no JSONB columns on this model
|
||||
|
||||
const computedAttributes = [
|
||||
{
|
||||
key: "courseCount", label: "Courses", type: "number", order: 100, filterable: false,
|
||||
literal: `(
|
||||
SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM "plan_courses"
|
||||
INNER JOIN "courses" ON "courses"."course_id" = "plan_courses"."course_id"
|
||||
WHERE "plan_courses"."plan_id" = "TierPlan"."plan_id"
|
||||
AND "courses"."deletedAt" IS NULL
|
||||
)`,
|
||||
},
|
||||
{
|
||||
key: "unitCount", label: "Units", type: "number", order: 101, filterable: false,
|
||||
literal: `(
|
||||
SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM "plan_units"
|
||||
INNER JOIN "units" ON "units"."unit_id" = "plan_units"."unit_id"
|
||||
WHERE "plan_units"."plan_id" = "TierPlan"."plan_id"
|
||||
AND "units"."deletedAt" IS NULL
|
||||
)`,
|
||||
},
|
||||
{
|
||||
key: "lessonCount", label: "Lessons", type: "number", order: 102, filterable: false,
|
||||
literal: `(
|
||||
SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM "plan_lessons"
|
||||
INNER JOIN "lessons" ON "lessons"."lesson_id" = "plan_lessons"."lesson_id"
|
||||
WHERE "plan_lessons"."plan_id" = "TierPlan"."plan_id"
|
||||
AND "lessons"."deletedAt" IS NULL
|
||||
)`,
|
||||
},
|
||||
{
|
||||
key: "bundleCount", label: "Bundles", type: "number", order: 103, filterable: false,
|
||||
literal: `(
|
||||
(SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM "plan_courses"
|
||||
INNER JOIN "courses" ON "courses"."course_id" = "plan_courses"."course_id"
|
||||
WHERE "plan_courses"."plan_id" = "TierPlan"."plan_id"
|
||||
AND "courses"."deletedAt" IS NULL)
|
||||
+
|
||||
(SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM "plan_units"
|
||||
INNER JOIN "units" ON "units"."unit_id" = "plan_units"."unit_id"
|
||||
WHERE "plan_units"."plan_id" = "TierPlan"."plan_id"
|
||||
AND "units"."deletedAt" IS NULL)
|
||||
+
|
||||
(SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM "plan_lessons"
|
||||
INNER JOIN "lessons" ON "lessons"."lesson_id" = "plan_lessons"."lesson_id"
|
||||
WHERE "plan_lessons"."plan_id" = "TierPlan"."plan_id"
|
||||
AND "lessons"."deletedAt" IS NULL)
|
||||
)`,
|
||||
},
|
||||
];
|
||||
|
||||
module.exports = { excludeAttributes, jsonbSchemas, computedAttributes };
|
||||
Reference in New Issue
Block a user