Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cog complexity on wordle setter index action #154

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/controllers/wordle_dictionaries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ def amend_dict
if !params[:new_words].present? || !params[:update_opt].present? || params[:valid_solutions].nil?
errors << "Please provide a list of valid words and select an update option"
else
new_words = params[:new_words].split("\n").map { |word|
{ word: word.chomp.strip, is_valid_solution: params[:valid_solutions] }
}
new_words = parse_words_from_str
delete_opt = params[:update_opt] == "replace"
add_opt = delete_opt || params[:update_opt] == "add" ? true : false
add_opt = delete_opt || params[:update_opt] == "add"
errors = update_db(new_words, delete_opt, add_opt)
end

Expand Down Expand Up @@ -120,6 +118,12 @@ def filter_only_solutions(query)
end
end

def parse_words_from_str
params[:new_words].split("\n").map { |word|
{ word: word.chomp.strip, is_valid_solution: params[:valid_solutions] }
}
end

def check_session_id
if session[:guest] == true
redirect_to wordles_play_path and return
Expand Down
Loading