<commit_before>class LessonPlanMilestone < ActiveRecord::Base
  attr_accessible :title, :description, :end_at

  belongs_to :course
  belongs_to :creator, class_name: "User"

  # Creates a virtual item of this class that is backed by some other data store.
  def self.create_virtual(*args)
    (Class.new do
        def initialize(other_entries)
          @other_entries = other_entries
        end

        def title
          "Other Items"
        end
        def description
          nil
        end
        def entries
          @other_entries
        end
        def end_at
          nil
        end

        def is_virtual
          true
        end
    end).new(*args)
  end
  
  def previous_milestone
    self.course.lesson_plan_milestones.where("end_at < :end_at", :end_at => self.end_at).order("end_at DESC").first
  end

  def entries
    # Find the entries where the end time is after the last milestone, if any
    # and less than or equal to this milestone's end time.
    previous_milestone = self.previous_milestone
    start_at = if previous_milestone then previous_milestone.end_at else nil end
    real_entries = LessonPlanEntry.where("end_at <= :end_at " +
      (if previous_milestone then "AND end_at > :start_at" else "" end) +
      " AND course_id = :course_id",
      :end_at => self.end_at, :start_at => start_at, :course_id => self.course_id)

    virtual_entries = course.lesson_plan_virtual_entries(start_at, self.end_at)
    
    viewable_entries = virtual_entries.select { |entry| entry.is_published }
    real_entries + viewable_entries
  end
<commit_msg>Revert "Preliminary filtering of unpublished virtual entries."<commit_after>class LessonPlanMilestone < ActiveRecord::Base
  attr_accessible :title, :description, :end_at

  belongs_to :course
  belongs_to :creator, class_name: "User"

  # Creates a virtual item of this class that is backed by some other data store.
  def self.create_virtual(*args)
    (Class.new do
        def initialize(other_entries)
          @other_entries = other_entries
        end

        def title
          "Other Items"
        end
        def description
          nil
        end
        def entries
          @other_entries
        end
        def end_at
          nil
        end

        def is_virtual
          true
        end
    end).new(*args)
  end
  
  def previous_milestone
    self.course.lesson_plan_milestones.where("end_at < :end_at", :end_at => self.end_at).order("end_at DESC").first
  end

  def entries
    # Find the entries where the end time is after the last milestone, if any
    # and less than or equal to this milestone's end time.
    previous_milestone = self.previous_milestone
    start_at = if previous_milestone then previous_milestone.end_at else nil end
    real_entries = LessonPlanEntry.where("end_at <= :end_at " +
      (if previous_milestone then "AND end_at > :start_at" else "" end) +
      " AND course_id = :course_id",
      :end_at => self.end_at, :start_at => start_at, :course_id => self.course_id)

    virtual_entries = course.lesson_plan_virtual_entries(start_at, self.end_at)
    real_entries + virtual_entries
  end

{'fraction_non_alphanumeric': 0.07310870947234584, 'fraction_numerical': 0.0, 'mean_word_length': 2.6850117096018735, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '4650652', 'n_tokens_mistral': 965, 'n_tokens_neox': 942, 'n_words': 270}