<commit_before>module Skr
    module Concerns

        # @see ClassMethods
        module VisibleIdIdentifier

            extend ActiveSupport::Concern

            module InstanceMethods

                # setup the visible id to the next available #{Skr::SequentialId}
                # @return [Integer] the assigned ID
                def assign_visible_id!
                    self.visible_id = Skr::SequentialId.next_for( self.class )
                end
            end


            # ### Visible ID Identifier Concern
            # This adds the {#has_visible_id} class methods
            module ClassMethods

                # An auto-incrementing number that's user-visible.
                # The visible_id is stored as an integer, but a string index is generated for
                # querying by the sql like operator. The **with_visible_id** scope is available for this purpose
                #
                # The next number an also be adjusted by the end-user by setting {Skr::SequentialId}
                # so they can set the numbers to start at
                # a specific point, which is useful for getting Invoice and other
                # numbers to match up to a legacy system
                def has_visible_id
                    include InstanceMethods
                    validates :visible_id, :presence=>{
                                  :message=>"ID was not set (should be automatically chosen)"
                              }
                    alias_attribute :record_identifier, :visible_id
                    before_validation :assign_visible_id!, :on=>:create

                    export_scope :with_visible_id, lambda{ | visid |
                        if visid.to_s =~/%/
                            where( 'cast(visible_id as varchar) like ?', visid.to_s )
                        else
                            where( 'cast(visible_id as varchar) = ?',    visid.to_s )
                        end
                    }

                end

            end
        end

    end
end
<commit_msg>Update to not overwrite visible_id if given<commit_after>module Skr
    module Concerns

        # @see ClassMethods
        module VisibleIdIdentifier

            extend ActiveSupport::Concern

            module InstanceMethods

                # setup the visible id to the next available #{Skr::SequentialId}
                # @return [Integer] the assigned ID
                def assign_visible_id!
                    self.visible_id ||= Skr::SequentialId.next_for( self.class )
                end
            end


            # ### Visible ID Identifier Concern
            # This adds the {#has_visible_id} class methods
            module ClassMethods

                # An auto-incrementing number that's user-visible.
                # The visible_id is stored as an integer, but a string index is generated for
                # querying by the sql like operator. The **with_visible_id** scope is available for this purpose
                #
                # The next number an also be adjusted by the end-user by setting {Skr::SequentialId}
                # so they can set the numbers to start at
                # a specific point, which is useful for getting Invoice and other
                # numbers to match up to a legacy system
                def has_visible_id
                    include InstanceMethods
                    validates :visible_id, :presence=>{
                                  :message=>"ID was not set (should be automatically chosen)"
                              }
                    alias_attribute :record_identifier, :visible_id
                    before_validation :assign_visible_id!, :on=>:create

                    export_scope :with_visible_id, lambda{ | visid |
                        if visid.to_s =~/%/
                            where( 'cast(visible_id as varchar) like ?', visid.to_s )
                        else
                            where( 'cast(visible_id as varchar) = ?',    visid.to_s )
                        end
                    }

                end

            end
        end

    end
end

{'fraction_non_alphanumeric': 0.0551257253384913, 'fraction_numerical': 0.0, 'mean_word_length': 1.3176470588235294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6803304', 'n_tokens_mistral': 1007, 'n_tokens_neox': 921, 'n_words': 334}