MCPcopy Create free account
hub / github.com/codecombat/codecombat / onCoursesSync

Method onCoursesSync

app/views/admin/AnalyticsView.js:562–586  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

560 }
561
562 onCoursesSync () {
563 return
564 this.courses.remove(this.courses.findWhere({ releasePhase: 'beta' }))
565 const sortedCourses = utils.sortCourses(this.courses.models != null ? this.courses.models : [])
566 this.courseOrderMap = {}
567 for (let i = 0, end = sortedCourses.length, asc = end >= 0; asc ? i < end : i > end; asc ? i++ : i--) { this.courseOrderMap[sortedCourses[i].get('_id')] = i }
568
569 let startDay = new Date()
570 startDay.setUTCDate(startDay.getUTCDate() - this.furthestCourseDayRange)
571 startDay = startDay.toISOString().substring(0, 10)
572 const options = {
573 url: '/db/course_instance/-/recent',
574 method: 'POST',
575 data: { startDay }
576 }
577 options.error = (models, response, options) => {
578 if (this.destroyed) { return }
579 return console.error('Failed to get recent course instances', response)
580 }
581 options.success = data => {
582 this.onCourseInstancesSync(data)
583 return (typeof this.renderSelectors === 'function' ? this.renderSelectors('#furthest-course') : undefined)
584 }
585 return this.supermodel.addRequestResource(options, 0).load()
586 }
587
588 onCourseInstancesSync (data) {
589 this.courseDistributionsRecent = []

Callers

nothing calls this directly

Calls 4

onCourseInstancesSyncMethod · 0.95
getMethod · 0.45
errorMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected