<commit_before>.unattached-promo-registrations
  .flex
    h1 Referral Promo
    hr
  .flex
    .panel.panel--double
      = form_tag admin_unattached_promo_registrations_path, id: "create-referral-codes" do
        .panel--header = "Create codes"
        hr
        .
          = number_field_tag "number_of_codes_to_create", nil, placeholder: "# of codes"
          = submit_tag "Create", class: "btn btn-info", style: "float:right;"
    .panel.panel--double
      = form_tag admin_promo_campaigns_path, id: "create-promo-campaign" do
        .panel--header = "Create campaigns"
        hr
        .
          = text_field_tag "campaign_name", nil, placeholder: "Campaign name"
          = submit_tag "Create", class: "btn btn-info", style: "float: right"
  .row
  .panel.panel--white.panel--table
    .panel--header = "Manage"
    . style="color: darkgrey; font-size: 14px; margin-bottom: 5px;"
      - if Rails.cache.fetch('unattached_promo_registration_stats_last_synced_at').nil?
        = "Stats have not been refreshed."
      - else 
        = "Stats last refreshed #{distance_of_time_in_words(Time.now - Rails.cache.fetch('unattached_promo_registration_stats_last_synced_at'))} ago. Stats in reports are always up-to-date."
    = form_tag admin_unattached_promo_registrations_path, method: :get, id: "filter-by-campaign" do
      = select_tag :filter, options_for_select(@campaigns + ["Not assigned", "All codes"], @current_campaign)
      = submit_tag "Filter by campaign", class: "btn btn-success"
    = form_tag admin_unattached_promo_registrations_path, method: :patch, id: "unattached-referral-code-form" do
      table.table
        tr
          th 
          th = "Code"
          th = "Campaign"
          th = "Installer Type"
          th
            = "Status"
            span.tf-tooltip
              span.icon= render "icon_help"
              span.tf-tooltip-content
                span.tf-tooltip-content-heading= "Status"
                span.tf-tooltip-content-content== "Downloads and installs will not be tracked when a code is 'paused'."
          th = "Downloads"
          th 
            = "Installs"
            span.tf-tooltip
              span.icon= render "icon_help"
              span.tf-tooltip-content
                span.tf-tooltip-content-heading= "Installs"
                span.tf-tooltip-content-content== "An install is counted when a user downloads the browser and opens it the first time."

          th
            = "Confirmed"
            span.tf-tooltip
              span.icon= render "icon_help"
              span.tf-tooltip-content
                span.tf-tooltip-content-heading= "Confirmed"
                span.tf-tooltip-content-content== "A confirmation is counted when a user downloads the browser and opens it, then opens it again at least 30 days later."
        tbody
          - @promo_registrations.each do |promo_registration| 
            - promo_registration_aggregate_stats = promo_registration.aggregate_stats
            tr
              td = check_box_tag "referral_codes[]", "#{promo_registration.referral_code}", 1
              td = promo_registration.referral_code
              td = promo_registration.promo_campaign&.name
              td = promo_registration.installer_type.nil? ? PromoRegistration::STANDARD : promo_registration.installer_type
              td = promo_registration.active ? "active" : "paused"
              td = promo_registration_aggregate_stats[PromoRegistration::RETRIEVALS] || 0
              td = promo_registration_aggregate_stats[PromoRegistration::FIRST_RUNS] || 0
              td = promo_registration_aggregate_stats[PromoRegistration::FINALIZED] || 0
      .flex
        .unattached-referral-code-form--submissions
          .panel
            .panel--sub-panel-header = "Assign codes to campaign"
            hr
            .flex.flex-one
              .flex-one = select_tag :promo_campaign_target, options_for_select(@campaigns)
              = hidden_field_tag :filter, params[:filter]
              = submit_tag "Assign", id: "assign-to-campaign", class: "btn btn-primary"
          .panel
            .panel--sub-panel-header = "Assign installer type to codes"
            hr
            .flex.flex-one
              .flex-one = select_tag :installer_type, options_for_select([["Mobile", PromoRegistration::MOBILE], ["Silent", PromoRegistration::SILENT], ["Standard", PromoRegistration::STANDARD]])
              = hidden_field_tag :filter, params[:filter]
              = submit_tag "Assign", id: "assign-installer-type", class: "btn btn-primary"
          .panel
            .panel--sub-panel-header = "Update code statuses"
            hr
            .flex
              .flex-one = select_tag :referral_code_status, options_for_select([["Active", "active"], ["Paused", "paused"]])
              = hidden_field_tag :filter, params[:filter]
              = submit_tag "Update", id: "update-referral-code-statuses", class: "btn btn-primary"
      .flex
        .panel
          .panel--sub-panel-header = "Report generation"
          hr
          .flex
            .flex-two.align-self-flex-center
              . = label_tag "Report period start"
              . = date_select :referral_code_report_period, :start
            .flex-two.align-self-flex-center
              . = label_tag "Report period end"
              . = date_select :referral_code_report_period, :end, default: 1.day.from_now
            .flex-two.align-self-flex-center
              . = label_tag "Reporting interval"
              . = select_tag :reporting_interval, options_for_select([["Daily",PromoRegistration::DAILY], ["Weekly",PromoRegistration::WEEKLY], ["Monthly",PromoRegistration::MONTHLY], ["Running total", PromoRegistration::RUNNING_TOTAL]])
            .flex-one.align-self-flex-center
              . style="font-weight: bold" = label_tag = "Event types"
              .
                = check_box_tag "event_types[]", PromoRegistration::RETRIEVALS, checked: true
                = label_tag = " " + event_type_column_header(PromoRegistration::RETRIEVALS)
              .<commit_msg>Use UTC date rather than using<commit_after>.unattached-promo-registrations
  .flex
    h1 Referral Promo
    hr
  .flex
    .panel.panel--double
      = form_tag admin_unattached_promo_registrations_path, id: "create-referral-codes" do
        .panel--header = "Create codes"
        hr
        .
          = number_field_tag "number_of_codes_to_create", nil, placeholder: "# of codes"
          = submit_tag "Create", class: "btn btn-info", style: "float:right;"
    .panel.panel--double
      = form_tag admin_promo_campaigns_path, id: "create-promo-campaign" do
        .panel--header = "Create campaigns"
        hr
        .
          = text_field_tag "campaign_name", nil, placeholder: "Campaign name"
          = submit_tag "Create", class: "btn btn-info", style: "float: right"
  .row
  .panel.panel--white.panel--table
    .panel--header = "Manage"
    . style="color: darkgrey; font-size: 14px; margin-bottom: 5px;"
      - if Rails.cache.fetch('unattached_promo_registration_stats_last_synced_at').nil?
        = "Stats have not been refreshed."
      - else 
        = "Stats last refreshed #{distance_of_time_in_words(Time.now - Rails.cache.fetch('unattached_promo_registration_stats_last_synced_at'))} ago. Stats in reports are always up-to-date."
    = form_tag admin_unattached_promo_registrations_path, method: :get, id: "filter-by-campaign" do
      = select_tag :filter, options_for_select(@campaigns + ["Not assigned", "All codes"], @current_campaign)
      = submit_tag "Filter by campaign", class: "btn btn-success"
    = form_tag admin_unattached_promo_registrations_path, method: :patch, id: "unattached-referral-code-form" do
      table.table
        tr
          th 
          th = "Code"
          th = "Campaign"
          th = "Installer Type"
          th
            = "Status"
            span.tf-tooltip
              span.icon= render "icon_help"
              span.tf-tooltip-content
                span.tf-tooltip-content-heading= "Status"
                span.tf-tooltip-content-content== "Downloads and installs will not be tracked when a code is 'paused'."
          th = "Downloads"
          th 
            = "Installs"
            span.tf-tooltip
              span.icon= render "icon_help"
              span.tf-tooltip-content
                span.tf-tooltip-content-heading= "Installs"
                span.tf-tooltip-content-content== "An install is counted when a user downloads the browser and opens it the first time."

          th
            = "Confirmed"
            span.tf-tooltip
              span.icon= render "icon_help"
              span.tf-tooltip-content
                span.tf-tooltip-content-heading= "Confirmed"
                span.tf-tooltip-content-content== "A confirmation is counted when a user downloads the browser and opens it, then opens it again at least 30 days later."
        tbody
          - @promo_registrations.each do |promo_registration| 
            - promo_registration_aggregate_stats = promo_registration.aggregate_stats
            tr
              td = check_box_tag "referral_codes[]", "#{promo_registration.referral_code}", 1
              td = promo_registration.referral_code
              td = promo_registration.promo_campaign&.name
              td = promo_registration.installer_type.nil? ? PromoRegistration::STANDARD : promo_registration.installer_type
              td = promo_registration.active ? "active" : "paused"
              td = promo_registration_aggregate_stats[PromoRegistration::RETRIEVALS] || 0
              td = promo_registration_aggregate_stats[PromoRegistration::FIRST_RUNS] || 0
              td = promo_registration_aggregate_stats[PromoRegistration::FINALIZED] || 0
      .flex
        .unattached-referral-code-form--submissions
          .panel
            .panel--sub-panel-header = "Assign codes to campaign"
            hr
            .flex.flex-one
              .flex-one = select_tag :promo_campaign_target, options_for_select(@campaigns)
              = hidden_field_tag :filter, params[:filter]
              = submit_tag "Assign", id: "assign-to-campaign", class: "btn btn-primary"
          .panel
            .panel--sub-panel-header = "Assign installer type to codes"
            hr
            .flex.flex-one
              .flex-one = select_tag :installer_type, options_for_select([["Mobile", PromoRegistration::MOBILE], ["Silent", PromoRegistration::SILENT], ["Standard", PromoRegistration::STANDARD]])
              = hidden_field_tag :filter, params[:filter]
              = submit_tag "Assign", id: "assign-installer-type", class: "btn btn-primary"
          .panel
            .panel--sub-panel-header = "Update code statuses"
            hr
            .flex
              .flex-one = select_tag :referral_code_status, options_for_select([["Active", "active"], ["Paused", "paused"]])
              = hidden_field_tag :filter, params[:filter]
              = submit_tag "Update", id: "update-referral-code-statuses", class: "btn btn-primary"
      .flex
        .panel
          .panel--sub-panel-header = "Report generation"
          hr
          .flex
            .flex-two.align-self-flex-center
              . = label_tag "Report period start"
              . = date_select :referral_code_report_period, :start
            .flex-two.align-self-flex-center
              . = label_tag "Report period end"
              . = date_select :referral_code_report_period, :end, default: Time.now.utc.to_date
            .flex-two.align-self-flex-center
              . = label_tag "Reporting interval"
              . = select_tag :reporting_interval, options_for_select([["Daily",PromoRegistration::DAILY], ["Weekly",PromoRegistration::WEEKLY], ["Monthly",PromoRegistration::MONTHLY], ["Running total", PromoRegistration::RUNNING_TOTAL]])
            .flex-one.align-self-flex-center
              . style="font-weight: bold" = label_tag = "Event types"
              .
                = check_box_tag "event_types[]", PromoRegistration::RETRIEVALS, checked: true
                = label_tag = " " + event_type_column_header(PromoRegistration::RETRIEVALS)
              .
{'fraction_non_alphanumeric': 0.10729192241590965, 'fraction_numerical': 0.001718634912840658, 'mean_word_length': 2.259535876233662, 'pattern_counts': {'":': 0, '<': 3, '<?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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7588674', 'n_tokens_mistral': 3636, 'n_tokens_neox': 3491, 'n_words': 733}