<commit_before>class StockMarketGameController < ApplicationController

	def index
	end

	def offset
		respond_to do |format|
			format.json { render json: {offset: Time.now.utc_offset}.to_json }
		end
	end

end<commit_msg>adding save and load game links<commit_after>class StockMarketGameController < ApplicationController

	include ApplicationHelper

	def index
		if !current_user
	    @user = User.new
	  end
	end

	def offset
		respond_to do |format|
			format.json { render json: {offset: Time.now.utc_offset}.to_json }
		end
	end


	def save
		if current_user
			p "#"*20
			p "*"*20
			saved_game = game_params[:saved_game]
			p "*"*20
			@user = current_user
			respond_to do |format|
				if @user.update(saved_game: saved_game)
					format.json { render json: {status: "success"}.to_json }
				else
					format.json { render json: {status: "failed to load game"}} 
				end
			end
		end
	end

	def load
		respond_to do |format|
			if current_user
				format.json { render json: {game: current_user.saved_game , stat: true}.to_json }
			else
				format.json { render json: {status: "failed to load game", stat: false} }
			end
		end
	end

	private

    def game_params
      params.require(:game).permit!
    end

end
{'fraction_non_alphanumeric': 0.08986928104575163, 'fraction_numerical': 0.004901960784313725, 'mean_word_length': 3.2387543252595155, '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': '4931394', 'n_tokens_mistral': 480, 'n_tokens_neox': 405, 'n_words': 120}