<commit_before># frozen_string_literal: true
# == Schema Information
#
# Table name: session_activations
#
#  id                       :integer          not null, primary key
#  session_id               :string           not null
#  created_at               :datetime         not null
#  updated_at               :datetime         not null
#  user_agent               :string           default(""), not null
#  ip                       :inet
#  access_token_id          :integer
#  user_id                  :integer          not null
#  web_push_subscription_id :integer
#

#  id              :bigint           not null, primary key
#  user_id         :bigint           not null
#  session_id      :string           not null
#  created_at      :datetime         not null
#  updated_at      :datetime         not null
#  user_agent      :string           default(""), not null
#  ip              :inet
#  access_token_id :bigint
#

class SessionActivation < ApplicationRecord
  belongs_to :user, inverse_of: :session_activations, required: true
  belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', dependent: :destroy
  belongs_to :web_push_subscription, class_name: 'Web::PushSubscription', dependent: :destroy

  delegate :token,
           to: :access_token,
           allow_nil: true

  def detection
    @detection ||= Browser.new(user_agent)<commit_msg>Remove duplicate annotate (#5910)<commit_after># frozen_string_literal: true
# == Schema Information
#
# Table name: session_activations
#
#  id                       :integer          not null, primary key
#  session_id               :string           not null
#  created_at               :datetime         not null
#  updated_at               :datetime         not null
#  user_agent               :string           default(""), not null
#  ip                       :inet
#  access_token_id          :integer
#  user_id                  :integer          not null
#  web_push_subscription_id :integer
#

class SessionActivation < ApplicationRecord
  belongs_to :user, inverse_of: :session_activations, required: true
  belongs_to :access_token, class_name: 'Doorkeeper::AccessToken', dependent: :destroy
  belongs_to :web_push_subscription, class_name: 'Web::PushSubscription', dependent: :destroy

  delegate :token,
           to: :access_token,
           allow_nil: true

  def detection
    @detection ||= Browser.new(user_agent)
{'fraction_non_alphanumeric': 0.074719800747198, 'fraction_numerical': 0.0016604400166044002, 'mean_word_length': 2.0238393977415305, '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': '7566520', 'n_tokens_mistral': 653, 'n_tokens_neox': 644, 'n_words': 177}