<commit_before>AB = Artificial.Base
AM = Artificial.Mirage
LOI = LandsOfIllusions
PAA = PixelArtAcademy

class PAA.PixelBoy.Apps.Journal.JournalView.Tasks extends AM.Component
  @id: -> 'PixelArtAcademy.PixelBoy.Apps.Journal.JournalView.Tasks'
  @version: -> '0.1.0'

  @register @id()
  template: -> @constructor.id()

  constructor: (@calendar) ->
    super
  
  onCreated: ->
    super

    @visible = new ReactiveField false

    @goals = new ComputedField =>
      return unless addedGoals = PAA.PixelBoy.Apps.StudyPlan.state()?.goals

      for goalId, goalData of addedGoals
        goalClass = PAA.Learning.Goal.getClassForId goalId
        new goalClass

    @goalTasks = new ComputedField =>
      return unless goals = @goals()

      goalTasks = []

      for goal in goals
        for task in goal.tasks()
          goalTasks.push
            _id: task.id()
            task: task
            goal: goal

      goalTasks

    @activeTasks = new ComputedField =>
      return unless activeGoalTasks = _.filter @goalTasks(), (goalTask) =>
        goalTask.task.active goalTask.goal.tasks()

      activeGoalTask.task for activeGoalTask in activeGoalTasks when activeGoalTask.type

    # Subscribe to character's task entries.
    PAA.Learning.Task.Entry.forCharacter.subscribe @, LOI.characterId()

  show: (callback) ->
    @visible true
    @_taskCallback = callback

  hide: ->
    @visible false
    
  visibleClass: ->
    'visible' if @visible()

  events: -><commit_msg>Fix for tasks not appearing.<commit_after>AB = Artificial.Base
AM = Artificial.Mirage
LOI = LandsOfIllusions
PAA = PixelArtAcademy

class PAA.PixelBoy.Apps.Journal.JournalView.Tasks extends AM.Component
  @id: -> 'PixelArtAcademy.PixelBoy.Apps.Journal.JournalView.Tasks'
  @version: -> '0.1.0'

  @register @id()
  template: -> @constructor.id()

  constructor: (@calendar) ->
    super
  
  onCreated: ->
    super

    @visible = new ReactiveField false

    @goals = new ComputedField =>
      return unless addedGoals = PAA.PixelBoy.Apps.StudyPlan.state()?.goals

      for goalId, goalData of addedGoals
        goalClass = PAA.Learning.Goal.getClassForId goalId
        new goalClass

    @goalTasks = new ComputedField =>
      return unless goals = @goals()

      goalTasks = []

      for goal in goals
        for task in goal.tasks()
          goalTasks.push
            _id: task.id()
            task: task
            goal: goal

      goalTasks

    @activeTasks = new ComputedField =>
      return unless activeGoalTasks = _.filter @goalTasks(), (goalTask) =>
        goalTask.task.active goalTask.goal.tasks()

      activeGoalTask.task for activeGoalTask in activeGoalTasks when activeGoalTask.task.type

    # Subscribe to character's task entries.
    PAA.Learning.Task.Entry.forCharacter.subscribe @, LOI.characterId()

  show: (callback) ->
    @visible true
    @_taskCallback = callback

  hide: ->
    @visible false
    
  visibleClass: ->
    'visible' if @visible()

  events: ->
{'fraction_non_alphanumeric': 0.102803738317757, 'fraction_numerical': 0.0020026702269692926, 'mean_word_length': 2.659340659340659, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '983884', 'n_tokens_mistral': 965, 'n_tokens_neox': 902, 'n_words': 222}