Skip to content

Instantly share code, notes, and snippets.

@shardiwal
Created July 6, 2020 09:29
Show Gist options
  • Save shardiwal/d454e0c71333902bbd9a12d569da0c19 to your computer and use it in GitHub Desktop.
Save shardiwal/d454e0c71333902bbd9a12d569da0c19 to your computer and use it in GitHub Desktop.
async findContentTypeVideos(ctx) {
let content = await this.findSingle(ctx);
let videoContentTypes = [];
let units = content.units;
if ( units ) {
units.forEach( async function(unit) {
let unit_content = unit.content;
if ( unit_content ) {
unit_content.forEach(function(uc) {
if ( uc.video_type ) {
console.log('unit_content_push');
videoContentTypes.push( uc.video_type );
}
});
}
let unit_lessons = unit.lessons;
if ( unit_lessons ) {
unit_lessons.forEach(async function(ul) {
let lesson = await strapi.query('lesson').findOne({ id: ul });
let lesson_scenario = lesson.scenario;
if ( lesson_scenario ) {
lesson_scenario.forEach(async function(uls) {
if ( uls.video_type ) {
console.log('lesson_scenario_push');
videoContentTypes.push( uls.video_type );
}
});
}
let lesson_learning_element = lesson.learningElementSection;
if ( lesson_learning_element ) {
lesson_learning_element.forEach(async function(ulle) {
if ( ulle.video_type ) {
console.log('lesson_learning_element_push');
videoContentTypes.push( ulle.video_type );
}
});
}
});
}
let unit_keywords = unit.keywords;
if ( unit_keywords ) {
unit_keywords.forEach(async function(uk) {
let unit_tag = await strapi.query('tag-type').findOne({ id: uk });
let tag_videos = unit_tag.videos;
if ( tag_videos ) {
tag_videos.forEach(async function(tagv) {
console.log('tag keyword push');
videoContentTypes.push( tagv );
});
}
});
}
});
}
console.log( videoContentTypes );
return videoContentTypes;
},
@shardiwal
Copy link
Author

shardiwal commented Jul 6, 2020

`
async findContentTypeVideos(ctx) {
let content = await this.findSingle(ctx);
let videoContentTypes = [];
let units = content.units;
if ( units ) {
units.forEach( async function(unit) {
let unit_content = unit.content;
if ( unit_content ) {
unit_content.forEach(function(uc) {
if ( uc.video_type ) {
console.log('unit_content_push');
videoContentTypes.push( uc.video_type );
}
});
}
let unit_lessons = unit.lessons;
if ( unit_lessons ) {
await Promise.all(unit_lessons.map(ul => {
let lesson = await strapi.query('lesson').findOne({ id: ul });
let lesson_scenario = lesson.scenario;
if ( lesson_scenario ) {
lesson_scenario.forEach(async function(uls) {
if ( uls.video_type ) {
console.log('lesson_scenario_push');
videoContentTypes.push( uls.video_type );
}
});
}
let lesson_learning_element = lesson.learningElementSection;
if ( lesson_learning_element ) {
lesson_learning_element.forEach(async function(ulle) {
if ( ulle.video_type ) {
console.log('lesson_learning_element_push');
videoContentTypes.push( ulle.video_type );
}
});
}
}));
}
let unit_keywords = unit.keywords;
if ( unit_keywords ) {
unit_keywords.forEach(async function(uk) {
let unit_tag = await strapi.query('tag-type').findOne({ id: uk });
let tag_videos = unit_tag.videos;
if ( tag_videos ) {
tag_videos.forEach(async function(tagv) {
console.log('tag keyword push');
videoContentTypes.push( tagv );
});
}
});
}
});
}
console.log( videoContentTypes );
return videoContentTypes;
},

`
What's wrong at unit_lessons ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment