<commit_before>class Admin::OrganisationsController < Admin::BaseController
  before_filter :load_organisation, only: [:edit, :update]
  before_filter :load_news_articles, only: [:edit, :update]

  def index
    @organisations = Organisation.all
  end

  def new
    @organisation = Organisation.new
  end

  def create
    @organisation = Organisation.new(params[:organisation])
    if @organisation.save
      redirect_to admin_organisations_path
    else
      render action: "new"
    end
  end

  def edit
  end

  def update
    if @organisation.update_attributes(params[:organisation])
      redirect_to admin_organisations_path
    else
      render action: "edit"
    end
  end

  private

  def load_organisation
    @organisation = Organisation.find(params[:id])
  end

  def load_news_articles
    @news_articles = NewsArticle.published.in_organisation(@organisation).order("updated_at desc")
  end
end<commit_msg>Use existing published scope for consistency.<commit_after>class Admin::OrganisationsController < Admin::BaseController
  before_filter :load_organisation, only: [:edit, :update]
  before_filter :load_news_articles, only: [:edit, :update]

  def index
    @organisations = Organisation.all
  end

  def new
    @organisation = Organisation.new
  end

  def create
    @organisation = Organisation.new(params[:organisation])
    if @organisation.save
      redirect_to admin_organisations_path
    else
      render action: "new"
    end
  end

  def edit
  end

  def update
    if @organisation.update_attributes(params[:organisation])
      redirect_to admin_organisations_path
    else
      render action: "edit"
    end
  end

  private

  def load_organisation
    @organisation = Organisation.find(params[:id])
  end

  def load_news_articles
    @news_articles = NewsArticle.published.in_organisation(@organisation).by_published_at
  end
end
{'fraction_non_alphanumeric': 0.07626666666666666, 'fraction_numerical': 0.0, 'mean_word_length': 3.8854166666666665, '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': '2488145', 'n_tokens_mistral': 582, 'n_tokens_neox': 541, 'n_words': 133}