<commit_before>import Ember from 'ember';
import DS from 'ember-data';
import PublishableModel from 'ilios/mixins/publishable-model';

const { computed, RSVP } = Ember;
const { all, defer, Promise} = RSVP;

export default DS.Model.extend(PublishableModel,{
  title: DS.attr('string'),
  shortTitle: DS.attr('string'),
  duration: DS.attr('number', { defaultValue: 1 }),
  school: DS.belongsTo('school', {async: true}),
  programYears: DS.hasMany('program-year', {
    async: true,
    inverse: 'program'
  }),
  directors: DS.hasMany('user', {
    async: true,
    inverse: 'directedPrograms'
  }),
  curriculumInventoryReports: DS.hasMany('curriculum-inventory-report', {async: true}),

  cohorts: computed('programYears.[]', function() {
    let deferred = defer();
    let allCohorts = [];
    let promises = [];
    promises.pushObject(new Promise(resolve => {
      this.get('programYears').then(programYears => {
        if(!programYears.length){
          resolve();
        }
        let promises = [];
        programYears.forEach(programYear => {
          promises.pushObject(programYear.get('cohort').then(cohort =>{
            allCohorts.pushObject(cohort);
          }));
        });
        all(promises).then(()=>{
          resolve();
        });
      });
    }));

    all(promises).then(()=>{
      deferred.resolve(allCohorts);
    });

    return DS.PromiseArray.create({
      promise: deferred.promise
    });
  }),

  courses: computed('cohorts.[]', function() {
    let deferred = defer();
    let allCourses = [];
    let promises = [];
    promises.pushObject(new Promise(resolve => {
      this.get('cohorts').then(cohorts => {
        if(!cohorts.length){
          resolve();
        }
        let promises = [];
        cohorts.forEach(cohort => {
          promises.pushObject(cohort.get('courses').then(courses =>{
            courses.forEach(course => {
              allCourses.pushObject(course);
            });
          }));
        });
        all(promises).then(()=>{
          resolve();<commit_msg>added docblocks to comp props.<commit_after>import Ember from 'ember';
import DS from 'ember-data';
import PublishableModel from 'ilios/mixins/publishable-model';

const { computed, RSVP } = Ember;
const { all, defer, Promise} = RSVP;

export default DS.Model.extend(PublishableModel,{
  title: DS.attr('string'),
  shortTitle: DS.attr('string'),
  duration: DS.attr('number', { defaultValue: 1 }),
  school: DS.belongsTo('school', {async: true}),
  programYears: DS.hasMany('program-year', {
    async: true,
    inverse: 'program'
  }),
  directors: DS.hasMany('user', {
    async: true,
    inverse: 'directedPrograms'
  }),
  curriculumInventoryReports: DS.hasMany('curriculum-inventory-report', {async: true}),

  /**
   * All cohorts associated with this program via its program years.
   * @property cohorts
   * @type {Ember.computed}
   * @public
   */
  cohorts: computed('programYears.[]', function() {
    let deferred = defer();
    let allCohorts = [];
    let promises = [];
    promises.pushObject(new Promise(resolve => {
      this.get('programYears').then(programYears => {
        if(!programYears.length){
          resolve();
        }
        let promises = [];
        programYears.forEach(programYear => {
          promises.pushObject(programYear.get('cohort').then(cohort =>{
            allCohorts.pushObject(cohort);
          }));
        });
        all(promises).then(()=>{
          resolve();
        });
      });
    }));

    all(promises).then(()=>{
      deferred.resolve(allCohorts);
    });

    return DS.PromiseArray.create({
      promise: deferred.promise
    });
  }),

  /**
   * All courses linked to this program via its program years/cohorts.
   * @property courses
   * @type {Ember.computed}
   * @public
   */
  courses: computed('cohorts.[]', function() {
    let deferred = defer();
    let allCourses = [];
    let promises = [];
    promises.pushObject(new Promise(resolve => {
      this.get('cohorts').then(cohorts => {
        if(!cohorts.length){
          resolve();
        }
        let promises = [];
        cohorts.forEach(cohort => {
          promises.pushObject(cohort.get('courses').then(courses =>{
            courses.forEach(course => {
              allCourses.pushObject(course);
            });
          }));
        });
        all(promises).then(()=>{
          resolve();
{'fraction_non_alphanumeric': 0.1633674630261661, 'fraction_numerical': 0.0004550625711035267, 'mean_word_length': 2.6062346185397867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1962070', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1332, 'n_words': 239}