<commit_before>import {
  BaseModel, identifiedBy, field, session, identifier, hasMany,
} from '../base';
import { action, computed, observable, Atom } from 'mobx';
import { sortBy, first, map, union } from 'lodash';
import { lazyInitialize } from 'core-decorators';
import TaskingPlan from '../tasking-plan';
import TaskPlanPublish from '../jobs/task-plan-publish';
import * as Dates from '../../helpers/dates';
import { TimeStore } from '../../flux/time';
import TaskPlanStats from './stats';
import TaskPlanReview from './review';

@identifiedBy('task-plan/teacher')
export default class TeacherTaskPlan extends BaseModel {

  @identifier id;
  @field title;
  @field type;

  @field ecosystem_id;
  @field({ type: 'date' }) first_published_at
  @field({ type: 'date' }) last_published_at;
  @session({ type: 'date' }) publish_last_requested_at;

  @field is_draft;
  @field is_preview;
  @field is_published;
  @field is_publishing;
  @field is_trouble;
  @field cloned_from_id;
  @field is_deleting;
  @session publish_job_url;
  @field({ type: 'object' }) settings;
  @hasMany({ model: TaskingPlan }) tasking_plans;

  @computed get isClone() {
    return !!this.cloned_from_id;
  }

  @observable publishingUpdates;

  constructor(attrs) {
    super(attrs);
    this.publishing = new Atom(
      'TaskPlanUpdates',
      () => { TaskPlanPublish.forPlan(this).startListening(); },
      () => { TaskPlanPublish.forPlan(this).stopListening(); },
    );

  }

  @lazyInitialize analytics = new TaskPlanStats({ taskPlan: this });

  @computed get isEvent() { return 'event' === this.type; }

  @computed get durationLength() {
    return this.duration.length('days');
  }

  @computed get opensAtDay() {
    const tp = first(sortBy(this.tasking_plans, 'opens_at'));
    return tp ? tp.opensAtDay : null;
  }

  @computed get duration() {
    return Dates.getDurationFromMoments(
      map(this.tasking_plans, 'due_at'),
    );
  }

  @action onPublishComplete() {
    this.is_published = true;<commit_msg>fix opens label on plan<commit_after>import {
  BaseModel, identifiedBy, field, session, identifier, hasMany,
} from '../base';
import { action, computed, observable, Atom } from 'mobx';
import { sortBy, first, map, union } from 'lodash';
import { lazyInitialize } from 'core-decorators';
import TaskingPlan from '../tasking-plan';
import TaskPlanPublish from '../jobs/task-plan-publish';
import * as Dates from '../../helpers/dates';
import { TimeStore } from '../../flux/time';
import TaskPlanStats from './stats';
import TaskPlanReview from './review';

@identifiedBy('task-plan/teacher')
export default class TeacherTaskPlan extends BaseModel {

  @identifier id;
  @field title;
  @field type;

  @field ecosystem_id;
  @field({ type: 'date' }) first_published_at
  @field({ type: 'date' }) last_published_at;
  @session({ type: 'date' }) publish_last_requested_at;

  @field is_draft;
  @field is_preview;
  @field is_published;
  @field is_publishing;
  @field is_trouble;
  @field cloned_from_id;
  @field is_deleting;
  @session publish_job_url;
  @field({ type: 'object' }) settings;
  @hasMany({ model: TaskingPlan }) tasking_plans;

  @computed get isClone() {
    return !!this.cloned_from_id;
  }

  @observable publishingUpdates;

  constructor(attrs) {
    super(attrs);
    this.publishing = new Atom(
      'TaskPlanUpdates',
      () => { TaskPlanPublish.forPlan(this).startListening(); },
      () => { TaskPlanPublish.forPlan(this).stopListening(); },
    );

  }

  @lazyInitialize analytics = new TaskPlanStats({ taskPlan: this });

  @computed get isEvent() { return 'event' === this.type; }

  @computed get durationLength() {
    return this.duration.length('days');
  }

  @computed get opensAtDay() {
    const tp = first(sortBy(this.tasking_plans, 'opens_at'));
    return tp ? tp.opensAtDay : null;
  }

  @computed get opensAt() {
    return this.opensAtDay.start().format('M/D');
  }

  @computed get duration() {
    return Dates.getDurationFromMoments(
      map(this.tasking_plans, 'due_at'),
    );
  }

  @action onPublishComplete() {
    this.is_published = true;
{'fraction_non_alphanumeric': 0.14504745680214165, 'fraction_numerical': 0.0, 'mean_word_length': 4.055350553505535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7375812', 'n_tokens_mistral': 1368, 'n_tokens_neox': 1341, 'n_words': 322}