<commit_before>	class StructureStep < Hydrant::Workflow::BasicStep
                def initialize(step = 'structure', title = "Structure", summary = "Organization of resources", template = 'structure')
                  super
                end

		def execute context
		  mediaobject = context[:mediaobject]

        if !context[:masterfile_ids].nil?
          masterFiles = []
          context[:masterfile_ids].each do |mf_id|
            mf = MasterFile.find(mf_id)
            masterFiles << mf
          end

          # Clean out the parts
          masterFiles.each do |mf|
            mediaobject.parts_remove mf
          end
          mediaobject.save(validate: false)
          
          # Puts parts back in order
          masterFiles.each do |mf|
            mf.container = mediaobject
            mf.save
          end
          mediaobject.save(validate: false)
        end
		  context
		end
	end<commit_msg>cleaning this up so that it reorders master files correctly<commit_after>  class StructureStep < Hydrant::Workflow::BasicStep
    def initialize(step = 'structure', title = "Structure", summary = "Organization of resources", template = 'structure')
      super
    end

    def execute context
      media_object = context[:mediaobject]

        if ! context[:masterfile_ids].nil?

          # gather the parts in the right order
          # in this situation we cannot use MatterFile.find([]) because
          # it will not return the results in the correct order
          master_files = context[:masterfile_ids].map{ |masterfile_id| MasterFile.find(masterfile_id) }

          # remove the parts
          media_object.parts.clear
          
          # re-add the parts that are now in the right order
          media_object.parts = master_files

          media_object.save 
        end
      context
    end
  end
{'fraction_non_alphanumeric': 0.07204767063921994, 'fraction_numerical': 0.0, 'mean_word_length': 2.0032520325203254, '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': '7192790', 'n_tokens_mistral': 484, 'n_tokens_neox': 459, 'n_words': 146}