-
Notifications
You must be signed in to change notification settings - Fork 5
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
Plug Batch info on Kitt callback and move back City on User to simplify validation logic. #325
Changes from 1 commit
c5f09b0
4850c9a
0a6f168
7e56926
52b3889
2b55247
f7205a4
837b0bc
07e6384
828396b
194c053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
wJoenn marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ class User < ApplicationRecord | |
CONTRIBUTORS = { pilou: "6788", aquaj: "449", louis: "19049", aurelie: "9168" }.freeze | ||
|
||
belongs_to :batch, optional: true | ||
belongs_to :city, optional: true | ||
belongs_to :city, optional: true, touch: true | ||
belongs_to :squad, optional: true, touch: true | ||
belongs_to :referrer, class_name: "User", optional: true | ||
|
||
|
@@ -42,13 +42,8 @@ def self.from_kitt(auth) | |
|
||
user = find_or_initialize_by(provider: auth.provider, uid: auth.uid) do |u| | ||
u.username = auth.info.github_nickname | ||
|
||
u.batch = Batch.find_or_initialize_by(number: oldest_batch&.camp&.slug.to_i) do |b| | ||
city = oldest_batch&.city | ||
b.city = City.find_or_initialize_by(name: city&.slug) | ||
end | ||
|
||
u.city = u.batch.city | ||
u.batch = Batch.find_or_initialize_by(number: oldest_batch&.camp&.slug.to_i) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Est-ce que ça veut dire qu'on crée un batch Edit : à choisir, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non validates :number, numericality: { in: 1...(2**31), message: "should be between 1 and 2^31" }, allow_nil: true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sauf que There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. La validation du Batch ne permet pas de creer un batch avec un |
||
u.city = City.find_or_initialize_by(name: oldest_batch&.city&.slug) | ||
end | ||
|
||
user.github_username = auth.info.github_nickname | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class RemoveCityAndSizeFromBatches < ActiveRecord::Migration[7.1] | ||
def change | ||
safety_assured { remove_column :batches, :city_id, :bigint } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non on en a besoin. C'est elle qui force l'User à s'aligner sur son batch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Y a pas de choix, donc y a pas besoin de forcer. Un user a pas de batch ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Je pense qu'il y a eu quiproquo: quand je dis "C'est elle qui force l'User à s'aligner sur son batch." ce que je veux dire c'est que c'est elle qui force l'User à s'aligner sur son batch dans notre modèle de donnée. Ça rend explicite une relation qui est seulement implicite ici. "Y'a pas de choix donc pas besoin de forcer" c'est pas un bon argument. On est dans la couche de cohérence des données là, la présence ou absence de choix est dans la couche applicative. C'est pas la mort de l'avoir enlevée, mais je trouve ça dommage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On pourra peut-être rétablir 🫣 |
||
safety_assured { remove_column :batches, :size, :int } | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai complètement oublié de passer sur les computers. Bien vu.