<commit_before>import Model, { hasMany, belongsTo, attr } from '@ember-data/model';
import { computed } from '@ember/object';
import ObjectProxy from '@ember/object/proxy';
import { all, map } from 'rsvp';
import { isEmpty } from '@ember/utils';
import moment from 'moment';
import sortableByPosition from 'ilios-common/utils/sortable-by-position';

const { alias, filterBy, mapBy, sum, oneWay, not, collect } = computed;

export default Model.extend({
  title: attr('string'),
  level: attr('number'),
  year: attr('number'),
  startDate: attr('date'),
  endDate: attr('date'),
  externalId: attr('string'),
  locked: attr('boolean'),
  archived: attr('boolean'),
  publishedAsTbd: attr('boolean'),
  published: attr('boolean'),
  clerkshipType: belongsTo('course-clerkship-type', { async: true }),
  school: belongsTo('school', { async: true }),
  directors: hasMany('user', {
    async: true,
    inverse: 'directedCourses',
  }),
  administrators: hasMany('user', {
    async: true,
    inverse: 'administeredCourses',
  }),
  studentAdvisors: hasMany('user', {
    async: true,
    inverse: 'studentAdvisedCourses',
  }),
  cohorts: hasMany('cohort', { async: true }),
  courseObjectives: hasMany('course-objective', { async: true }),
  meshDescriptors: hasMany('mesh-descriptor', { async: true }),
  learningMaterials: hasMany('course-learning-material', { async: true }),
  sessions: hasMany('session', { async: true }),
  ancestor: belongsTo('course', {
    inverse: 'descendants',
    async: true,
  }),
  descendants: hasMany('course', {
    inverse: 'ancestor',
    async: true,
  }),
  terms: hasMany('term', { async: true }),

  publishedSessions: filterBy('sessions', 'isPublished'),
  publishedSessionOfferings: mapBy('publishedSessions', 'offerings'),
  publishedSessionOfferingCounts: mapBy('publishedSessionOfferings', 'length'),
  publishedOfferingCount: sum('publishedSessionOfferingCounts'),

  academicYear: computed('year', function () {
    return this.year + ' - ' + (parseInt(this.year, 10) + 1);
  }),

  /**
   * All competencies linked to this course via its objectives.
   * @property competencies
   * @type {Ember.computed}
   * @public
   */
  competencies: computed('courseObjectives.@each.treeCompetencies', async function () {
    const courseObjectives = await this.courseObjectives;
    const trees = await all(courseObjectives.mapBy('treeCompetencies'));
    const competencies = trees.reduce((array, set) => {
      return array.pushObjects(set);<commit_msg>rb obsolete academicYear CP.<commit_after>import Model, { hasMany, belongsTo, attr } from '@ember-data/model';
import { computed } from '@ember/object';
import ObjectProxy from '@ember/object/proxy';
import { all, map } from 'rsvp';
import { isEmpty } from '@ember/utils';
import moment from 'moment';
import sortableByPosition from 'ilios-common/utils/sortable-by-position';

const { alias, filterBy, mapBy, sum, oneWay, not, collect } = computed;

export default Model.extend({
  title: attr('string'),
  level: attr('number'),
  year: attr('number'),
  startDate: attr('date'),
  endDate: attr('date'),
  externalId: attr('string'),
  locked: attr('boolean'),
  archived: attr('boolean'),
  publishedAsTbd: attr('boolean'),
  published: attr('boolean'),
  clerkshipType: belongsTo('course-clerkship-type', { async: true }),
  school: belongsTo('school', { async: true }),
  directors: hasMany('user', {
    async: true,
    inverse: 'directedCourses',
  }),
  administrators: hasMany('user', {
    async: true,
    inverse: 'administeredCourses',
  }),
  studentAdvisors: hasMany('user', {
    async: true,
    inverse: 'studentAdvisedCourses',
  }),
  cohorts: hasMany('cohort', { async: true }),
  courseObjectives: hasMany('course-objective', { async: true }),
  meshDescriptors: hasMany('mesh-descriptor', { async: true }),
  learningMaterials: hasMany('course-learning-material', { async: true }),
  sessions: hasMany('session', { async: true }),
  ancestor: belongsTo('course', {
    inverse: 'descendants',
    async: true,
  }),
  descendants: hasMany('course', {
    inverse: 'ancestor',
    async: true,
  }),
  terms: hasMany('term', { async: true }),

  publishedSessions: filterBy('sessions', 'isPublished'),
  publishedSessionOfferings: mapBy('publishedSessions', 'offerings'),
  publishedSessionOfferingCounts: mapBy('publishedSessionOfferings', 'length'),
  publishedOfferingCount: sum('publishedSessionOfferingCounts'),

  /**
   * All competencies linked to this course via its objectives.
   * @property competencies
   * @type {Ember.computed}
   * @public
   */
  competencies: computed('courseObjectives.@each.treeCompetencies', async function () {
    const courseObjectives = await this.courseObjectives;
    const trees = await all(courseObjectives.mapBy('treeCompetencies'));
    const competencies = trees.reduce((array, set) => {
      return array.pushObjects(set);
{'fraction_non_alphanumeric': 0.15648621041879468, 'fraction_numerical': 0.0006128702757916241, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2187951', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1483, 'n_words': 348}