mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 02:09:07 +03:00
refactor: refactored course service
This commit is contained in:
parent
7149a0f3eb
commit
0472036b66
@ -16,7 +16,7 @@ export default class CourseHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static getMaterialFileNames(course: Course): FileEntry[] {
|
public static getMaterialFileNames(course: Course): FileEntry[] {
|
||||||
const data = course.lessons.map(l => l.materials.map(m => ({ path: 'materials/', name: m.name }))).flat();
|
const data = course.lessons.flatMap(l => l.materials.map(m => ({ path: 'materials/', name: m.name })));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -732,11 +732,8 @@ export default class CourseService {
|
|||||||
* Collect file names
|
* Collect file names
|
||||||
*/
|
*/
|
||||||
const images = courses.map(course => CourseHelper.getImageFileName(course)).filter(Boolean) as FileEntry[];
|
const images = courses.map(course => CourseHelper.getImageFileName(course)).filter(Boolean) as FileEntry[];
|
||||||
const videos = courses
|
const videos = courses.flatMap(course => CourseHelper.getVideoFileNames(course)).filter(Boolean) as FileEntry[];
|
||||||
.map(course => CourseHelper.getVideoFileNames(course))
|
const materials = courses.flatMap(course => CourseHelper.getMaterialFileNames(course));
|
||||||
.flat()
|
|
||||||
.filter(Boolean) as FileEntry[];
|
|
||||||
const materials = courses.map(course => CourseHelper.getMaterialFileNames(course)).flat();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove files from disk
|
* Remove files from disk
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user