MCPcopy Index your code
hub / github.com/codecombat/codecombat / prepaidIncludesCourse

Method prepaidIncludesCourse

app/models/User.js:945–954  ·  view source on GitHub ↗
(course)

Source from the content-addressed store, hash-verified

943 }
944
945 prepaidIncludesCourse (course) {
946 const courseProducts = this.activeProducts('course')
947 if (!courseProducts.length) { return false }
948 // NOTE: Full licenses implicitly include all courses
949 if (_.any(courseProducts, p => (p.productOptions?.includedCourseIDs == null))) { return true }
950 const union = (res, prepaid) => _.union(res, prepaid.productOptions?.includedCourseIDs != null ? prepaid.productOptions?.includedCourseIDs : [])
951 const includedCourseIDs = _.reduce(courseProducts, union, [])
952 const courseID = course.id || course
953 return includedCourseIDs.includes(courseID)
954 }
955
956 findCourseProduct (prepaidId) {
957 return _.find(this.activeProducts('course'), p => (p.prepaid + '') === (prepaidId + ''))

Callers 2

assignCourseFunction · 0.80
assignCourseMethod · 0.80

Calls 1

activeProductsMethod · 0.95

Tested by

no test coverage detected