IIIRR-29 Update for issue in tables and prevent answer duplication#23
Conversation
| @@ -40,23 +40,29 @@ def handle(event) | |||
| return | |||
| end | |||
|
|
|||
There was a problem hiding this comment.
I removed this as it was repetitive.
| embeds: [ answer_embed(answer, puzzle) ], | ||
| ephemeral: true # Only the user sees this message | ||
| ) | ||
| else |
There was a problem hiding this comment.
After looking further into this it seems as though answer should always be nil if the validation fails or the db index unique fails, so the if/else should work here.
| belongs_to :puzzle | ||
| belongs_to :user | ||
|
|
||
| validates :puzzle_id, uniqueness: { scope: [ :user_id, :server_id ] } |
There was a problem hiding this comment.
Add an extra layer of validation
| @@ -1,3 +1,4 @@ | |||
| class Server < ApplicationRecord | |||
| has_and_belongs_to_many :users, join_table: "users_servers" | |||
There was a problem hiding this comment.
I am not sure how this was working before
| has_and_belongs_to_many :servers | ||
| has_many :servers | ||
| has_and_belongs_to_many :servers, join_table: "users_servers" | ||
| has_many :answers |
There was a problem hiding this comment.
Remove repetitive servers, I think this must have been a mistake and was supposed to be answers.
| @@ -0,0 +1,5 @@ | |||
| class AddUniqueIndexToAnswers < ActiveRecord::Migration[8.0] | |||
There was a problem hiding this comment.
Add migration with db uniqueness for each answer
| @@ -1,19 +1,47 @@ | |||
|
|
|||
| # db/seeds.rb | |||
|
|
|||
There was a problem hiding this comment.
While testing this in the rails console I was having several issues so I updated the seed file to more closely resemble the relationships.
Bump kamal from 2.5.3 to 2.6.1
This PR attempts to fix the issues we are seeing with the weekly leaderboard not having the correct scores, and multiple entries being created in the db for one answer.
I also noticed that there were some issues with the way that the active record models were configured when it came to their relationships, so I updated that as well.