mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
ready
This commit is contained in:
@@ -337,11 +337,11 @@ exports.getAsset = async (req, res) => {
|
||||
// └─────────────────────────────────────────────────────────────────────────┘
|
||||
//
|
||||
// Shared by the single-file POST / and the multi-file POST /batch routes.
|
||||
// `requireVideoThumbnail` is false for batch uploads — a bulk drop has no
|
||||
// per-file thumbnail step, so videos land with thumbnail_url null and pick
|
||||
// one up later via the existing "thumbnail-only" path in updateAsset().
|
||||
// Thumbnails are optional for both video and audio — a video/audio asset can
|
||||
// land with thumbnail_url null and pick one up later via the existing
|
||||
// "thumbnail-only" path in updateAsset().
|
||||
//
|
||||
async function createAssetFromUpload({ file, thumbFile, body, user, requireVideoThumbnail = true, uploadId }) {
|
||||
async function createAssetFromUpload({ file, thumbFile, body, user, uploadId }) {
|
||||
const uploadedFiles = []; // [{ key, provider }]
|
||||
|
||||
try {
|
||||
@@ -367,10 +367,6 @@ async function createAssetFromUpload({ file, thumbFile, body, user, requireVideo
|
||||
const checksum = file.buffer ? resolveChecksum(file.buffer) : null;
|
||||
const usesProvider = ["chibisafe", "s3"].includes(storage_provider);
|
||||
|
||||
if (file_type === "video" && requireVideoThumbnail && !thumbFile) {
|
||||
throw Object.assign(new Error("A thumbnail image is required for video uploads."), { status: 400 });
|
||||
}
|
||||
|
||||
if (usesProvider && !file.buffer) {
|
||||
throw Object.assign(new Error("File buffer is required. Ensure multer uses memoryStorage."), { status: 400 });
|
||||
}
|
||||
@@ -575,7 +571,6 @@ exports.uploadAssetsBatch = async (req, res) => {
|
||||
createdBy,
|
||||
},
|
||||
user: req.user,
|
||||
requireVideoThumbnail: false,
|
||||
});
|
||||
results.push({ originalname: file.originalname, success: true, data: asset });
|
||||
} catch (err) {
|
||||
|
||||
@@ -55,6 +55,21 @@ async function recomputeParentDurations(lessonId) {
|
||||
}
|
||||
|
||||
const LESSON_LIST_COMPUTED = [
|
||||
{
|
||||
// Not its own column — consumed by the Title cell on the frontend to
|
||||
// prefix "(UNIT)" when a lesson is already attached to at least one Unit.
|
||||
key: "unit_count",
|
||||
label: "Unit Count",
|
||||
type: "number",
|
||||
hidden: true,
|
||||
filterable: false,
|
||||
literal: `(
|
||||
SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM unit_lessons ul
|
||||
JOIN units u ON u.unit_id = ul.unit_id AND u."deletedAt" IS NULL
|
||||
WHERE ul.lesson_id = "Lesson"."lesson_id"
|
||||
)`,
|
||||
},
|
||||
{
|
||||
key: "course_count",
|
||||
label: "Affiliated",
|
||||
@@ -74,6 +89,7 @@ const LESSON_LIST_COMPUTED = [
|
||||
label: "Course Status",
|
||||
type: "text",
|
||||
order: 3, // 1: Title, 2: Affiliated, 3: Course Status — see lessons.mdl.js
|
||||
hidden: true,
|
||||
filterable: false,
|
||||
literal: `(
|
||||
CASE
|
||||
|
||||
@@ -72,10 +72,13 @@ const UNIT_LIST_COMPUTED = [
|
||||
)`,
|
||||
},
|
||||
{
|
||||
// Not its own column — consumed by the Title cell on the frontend to
|
||||
// show a "Course" badge when a unit is already attached to at least one Course.
|
||||
key: "course_count",
|
||||
label: "Affiliated",
|
||||
type: "number",
|
||||
order: 2, // 1: Title, 2: Affiliated, 3: Subscription, 4: Duration — see units.mdl.js
|
||||
hidden: true,
|
||||
literal: `(
|
||||
SELECT CAST(COUNT(*) AS INTEGER)
|
||||
FROM course_units cu
|
||||
@@ -88,6 +91,7 @@ const UNIT_LIST_COMPUTED = [
|
||||
label: "Course Status",
|
||||
type: "text",
|
||||
order: 3, // 1: Title, 2: Affiliated, 3: Course Status, 4: Subscription, 5: Duration — see units.mdl.js
|
||||
hidden: true,
|
||||
filterable: false,
|
||||
literal: `(
|
||||
CASE
|
||||
|
||||
Reference in New Issue
Block a user