<commit_before>require 'pivotal/story'

module Pivotal
  class Project

    class << self
      def create_new_release_marker(name)
        opts = { name: name, accepted_at: Time.now.utc.iso8601, story_type: 'release' }
        Story.create(opts)
      end

      def move_stories_above_release_marker

      end

      def add_release_label_to_stories(label_name, stories)
        stories.each do |story|
          story.add_label(label_name)
        end
      end

      def last_release_id
        # FIXME
        112066197
      end

      def delivered_unreleased_stories
        filters = { after_story_id: last_release_id, with_state: :accepted }
        Story.where(filters).select {|s| s.story_type != 'release'}
      end
    end

  end
end<commit_msg>Create helper for post release cleanup<commit_after>require 'pivotal/story'

module Pivotal
  class Project

    class << self
      def update_for_release(release_label)
        stories = delivered_unreleased_stories
        add_release_label_to_stories(stories, release_label)
        after_id = stories.sort_by(&:accepted_at).last.id

        marker_name = release_label.capitalize.gsub('_', ' ')
        create_new_release_marker(marker_name, after_id)
      end

      def create_new_release_marker(name, after_id=nil)
        opts = { name: name, accepted_at: Time.now.utc.iso8601, story_type: 'release', after_id: after_id }
        opts.delete_if {|k,v| v.nil?}

        Story.create(opts)
      end

      def add_release_label_to_stories(stories, label_name)
        stories.each do |story|
          story.add_label(label_name)
        end
      end

      def last_release_id
        # FIXME
        112066197
      end

      def delivered_unreleased_stories
        filters = { after_story_id: last_release_id, with_state: :accepted }
        Story.where(filters).select {|s| s.story_type != 'release'}
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.07918196119559517, 'fraction_numerical': 0.013633980073413739, 'mean_word_length': 2.606805293005671, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1909518', 'n_tokens_mistral': 640, 'n_tokens_neox': 610, 'n_words': 122}