<commit_before>class PostsController < ApplicationController
  load_resource :post,
    find_by: :short_sha,
    through: :current_site

  def index
    @posts = @posts.fresh.order('created_at DESC')
    respond_with @posts
  end

  def show
    respond_with @post
  end

  def create
    @post.save
    respond_with @post, location: :root
  end

  def edit
    respond_with @post
  end

  def update
    @successor = @post.dup
    @successor.attributes = post_params

    if @successor.valid? && @successor.sha != @post.sha
      @post.update_attributes(successor_sha: @successor.sha)
      @successor.save
      @post = @successor
    else
      @post.update_attributes(post_params)<commit_msg>Also copy timestamp when creating duplicate post<commit_after>class PostsController < ApplicationController
  load_resource :post,
    find_by: :short_sha,
    through: :current_site

  def index
    @posts = @posts.fresh.order('created_at DESC')
    respond_with @posts
  end

  def show
    respond_with @post
  end

  def create
    @post.save
    respond_with @post, location: :root
  end

  def edit
    respond_with @post
  end

  def update
    @successor = @post.dup
    @successor.created_at = @post.created_at
    @successor.attributes = post_params

    if @successor.valid? && @successor.sha != @post.sha
      @post.update_attributes(successor_sha: @successor.sha)
      @successor.save
      @post = @successor
    else
      @post.update_attributes(post_params)
{'fraction_non_alphanumeric': 0.08899456521739131, 'fraction_numerical': 0.0, 'mean_word_length': 3.184659090909091, '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': '4209924', 'n_tokens_mistral': 484, 'n_tokens_neox': 465, 'n_words': 111}