<commit_before>class AnnouncementsController < ApplicationController
  load_and_authorize_resource :course
  load_and_authorize_resource :announcement, through: :course, except: [:index]

  before_filter :load_general_course_data, only: [:show, :index, :edit, :new]

  def index
    @is_new = {}
    paging_pref = @course.announcements_paging_pref.prefer_value.to_i
    @announcements = @course.announcements.accessible_by(current_ability)
                        .order("publish_at DESC").page(params[:page]).per(paging_pref)
    if curr_user_course.id
      unseen = @announcements - curr_user_course.seen_announcements.first(30)
      unseen.each do |ann|
        @is_new[ann.id] = true
        curr_user_course.mark_as_seen(ann)
      end
    end
  end

  def new
    @announcement.publish_at = DateTime.now.beginning_of_day
  end

  def edit
  end

  def create
    @announcement.creator = current_user
    respond_to do |format|
      if @announcement.save
        @announcement.schedule_mail(@course.user_courses, course_announcements_url(@course))
        format.html { redirect_to course_announcements_url(@course),
                      notice: "The announcement '#{@announcement.title}' has been created." }
      else
        format.html { render action: "new" }
      end
    end
  end

  def update
    respond_to do |format|
      if @announcement.update_attributes(params[:announcement])
        @announcement.schedule_mail(@course.user_courses, course_announcements_url(@course))
        format.html { redirect_to course_announcements_url(@course),<commit_msg>announcement publish default to current time<commit_after>class AnnouncementsController < ApplicationController
  load_and_authorize_resource :course
  load_and_authorize_resource :announcement, through: :course, except: [:index]

  before_filter :load_general_course_data, only: [:show, :index, :edit, :new]

  def index
    @is_new = {}
    paging_pref = @course.announcements_paging_pref.prefer_value.to_i
    @announcements = @course.announcements.accessible_by(current_ability)
                        .order("publish_at DESC").page(params[:page]).per(paging_pref)
    if curr_user_course.id
      unseen = @announcements - curr_user_course.seen_announcements.first(30)
      unseen.each do |ann|
        @is_new[ann.id] = true
        curr_user_course.mark_as_seen(ann)
      end
    end
  end

  def new
    @announcement.publish_at = DateTime.now
  end

  def edit
  end

  def create
    @announcement.creator = current_user
    respond_to do |format|
      if @announcement.save
        @announcement.schedule_mail(@course.user_courses, course_announcements_url(@course))
        format.html { redirect_to course_announcements_url(@course),
                      notice: "The announcement '#{@announcement.title}' has been created." }
      else
        format.html { render action: "new" }
      end
    end
  end

  def update
    respond_to do |format|
      if @announcement.update_attributes(params[:announcement])
        @announcement.schedule_mail(@course.user_courses, course_announcements_url(@course))
        format.html { redirect_to course_announcements_url(@course),
{'fraction_non_alphanumeric': 0.09185606060606061, 'fraction_numerical': 0.0012626262626262627, 'mean_word_length': 3.5206847360912983, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6976055', 'n_tokens_mistral': 1007, 'n_tokens_neox': 990, 'n_words': 184}