<commit_before>require 'exponent-server-sdk'

class Api::V1::TokensController < ApplicationController
  def create
    # You probably actually want to associate this with a user,
    # otherwise it's not particularly useful
    @user = User.find(params[:token][:user_id])

    message = ''
    if @user.push_token.present?
      @token = @user.push_token
      message = 'Welcome back!'
    else
      @user.update_attribute(:push_token, params[:token][:push_token])
      @token = @user.push_token
      message = 'Welcome to Expo'
    end
    binding.pry
    exponent.publish(
      exponentPushToken: @token,
      message: message,
      data: {a: 'Welcome to Lunch Blast'}, # Data is required, pass any arbitrary data to include with the notification
    )

    render json: {success: true}
  end

  private

  def token_params
    params.permit(:push_token, :user_id)
  end

  def exponent
    @exponent ||= Exponent::Push::Client.new
  end
end<commit_msg>remove pry<commit_after>require 'exponent-server-sdk'

class Api::V1::TokensController < ApplicationController
  def create
    # You probably actually want to associate this with a user,
    # otherwise it's not particularly useful
    @user = User.find(params[:token][:user_id])

    message = ''
    if @user.push_token.present?
      @token = @user.push_token
      message = 'Welcome back!'
    else
      @user.update_attribute(:push_token, params[:token][:push_token])
      @token = @user.push_token
      message = 'Welcome to Expo'
    end

    exponent.publish(
      exponentPushToken: @token,
      message: message,
      data: {a: 'Welcome to Lunch Blast'}, # Data is required, pass any arbitrary data to include with the notification
    )

    render json: {success: true}
  end

  private

  def token_params
    params.permit(:push_token, :user_id)
  end

  def exponent
    @exponent ||= Exponent::Push::Client.new
  end
end
{'fraction_non_alphanumeric': 0.10230849947534103, 'fraction_numerical': 0.001049317943336831, 'mean_word_length': 3.2283813747228383, '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': '1204085', 'n_tokens_mistral': 584, 'n_tokens_neox': 572, 'n_words': 165}