<commit_before>module Hippo::API::Handlers

    class Tenant < Hippo::API::ControllerBase
        PUBLIC_ATTRS = %w{slug name}

        def show
            std_api_reply(:retrieve, Hippo::Tenant.current, only: PUBLIC_ATTRS)
        end

        # isn't really a create, but FE will think it's creating because we don't expose the id
        def create
            tenant = Hippo::Tenant.current
            tenant.assign_attributes(data.slice(*PUBLIC_ATTRS))
            success = tenant.save
            if success
                Hippo::Tenant.system.perform do
                    Hippo::Templates::TenantChange.create(tenant).deliver
                end
            end
            std_api_reply(:update, tenant,
                          only: PUBLIC_ATTRS,
                          success: success)
        end
    end

end<commit_msg>Only send email if slug has actually changed<commit_after>module Hippo::API::Handlers

    class Tenant < Hippo::API::ControllerBase
        PUBLIC_ATTRS = %w{slug name}

        def show
            std_api_reply(:retrieve, Hippo::Tenant.current, only: PUBLIC_ATTRS)
        end

        # isn't really a create, but FE will think it's creating because we don't expose the id
        def create
            tenant = Hippo::Tenant.current
            tenant.assign_attributes(data.slice(*PUBLIC_ATTRS))
            success = tenant.save
            if success && tenant.slug_previously_changed?
                Hippo::Tenant.system.perform do
                    Hippo::Templates::TenantChange.create(tenant).deliver
                end
            end
            std_api_reply(:update, tenant,
                          only: PUBLIC_ATTRS,
                          success: success)
        end
    end

end
{'fraction_non_alphanumeric': 0.07411630558722919, 'fraction_numerical': 0.0, 'mean_word_length': 1.7379095163806553, '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': '7637449', 'n_tokens_mistral': 495, 'n_tokens_neox': 464, 'n_words': 115}