-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[20325][20701] Replace dynamic finders, fix ActiveRecord deprecation warnings #3194
[20325][20701] Replace dynamic finders, fix ActiveRecord deprecation warnings #3194
Conversation
I've prepared a stage to preview changes. Open stage or view logs. |
@@ -153,7 +153,7 @@ | |||
let(:child_project) { FactoryGirl.create(:project, parent: project) } | |||
let(:shared_version) { FactoryGirl.create(:version, project: project, sharing: 'descendants') } | |||
|
|||
before { get :index, ids: shared_version.id.to_s, project_id: child_project.id, format: :json } | |||
before do get :index, ids: shared_version.id.to_s, project_id: child_project.id, format: :json 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.
Line is too long. [108/100]
This patch replaces all dynamic finders, for the sake of consistency, although only some methods are deprecated. See: https://github.com/rails/activerecord-deprecated_finders#active-record-deprecated-finders * Revert some `User#find_by_login` usages in cuke steps accidentally removed in 74228b5. User Story # 20325 Signed-off-by: Alex Coles <[email protected]>
`.find_or_create_by` will call `.first`. Signed-off-by: Alex Coles <[email protected]>
Signed-off-by: Alex Coles <[email protected]>
Signed-off-by: Alex Coles <[email protected]>
Signed-off-by: Alex Coles <[email protected]>
@@ -128,8 +128,7 @@ def migrate_planning_element_types(timelines_opts, pe_type_id_map, calling_class | |||
|
|||
calling_class.contains_none_element = calling_class.contains_none_element? || pe_types.empty? | |||
|
|||
pe_types = pe_types.empty? ? new_ids_of_former_pes | |||
: pe_types.map { |p| pe_type_id_map[p.to_i].to_s } | |||
pe_types = pe_types.empty? ? new_ids_of_former_pes : pe_types.map { |p| pe_type_id_map[p.to_i].to_s } |
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.
Line is too long. [105/100]
This reverts commit 8e47f60.
You should see my hint on calling I think since the introduction of |
Pew... reviewed until the latest commit:
Looking nice (and tedious) :) |
Reported as issue upstream: rubocop/rubocop#2021 [ci skip] Signed-off-by: Alex Coles <[email protected]>
[ci skip] Signed-off-by: Alex Coles <[email protected]>
Missed by rubocop auto-correct. [ci skip] Signed-off-by: Alex Coles <[email protected]>
current_language.to_s.downcase == 'ja' || | ||
current_language.to_s.downcase == 'zh' || | ||
current_language.to_s.downcase == 'zh-tw' || | ||
if current_language.to_s.downcase == 'ko' || current_language.to_s.downcase == 'ja' || current_language.to_s.downcase == 'zh' || current_language.to_s.downcase == 'zh-tw' || |
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.
Line is too long. [178/100]
Unnecessary spacing detected.
…namic-finders Signed-off-by: Alex Coles <[email protected]>
[ci skip] Signed-off-by: Alex Coles <[email protected]>
current_language.to_s.downcase == 'ja' || | ||
current_language.to_s.downcase == 'zh' || | ||
current_language.to_s.downcase == 'zh-tw' || | ||
if current_language.to_s.downcase == 'ko' || current_language.to_s.downcase == 'ja' || current_language.to_s.downcase == 'zh' || current_language.to_s.downcase == 'zh-tw' || |
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.
Line is too long. [178/100]
Unnecessary spacing detected.
Signed-off-by: Alex Coles <[email protected]>
Thanks!
Yes, sure is tedious. I think I've now dealt with all of your comments, with the exception of reordering
I reported one of the issues upstream (rubocop/rubocop#2021). I tend to be optimistic though, and think |
@@ -164,7 +165,7 @@ def find_all_projects_by_project_id | |||
# WTF. Why do we completely skip rewiring in this case and always provide parent_ids? | |||
# This is totally inconistent. | |||
identifiers = params[:ids].split(/,/).map(&:strip) | |||
@planning_elements = WorkPackage.visible(User.current).find_all_by_id(identifiers) | |||
@planning_elements = WorkPackage.visible(User.current).where(id: identifiers) |
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.
This now returns an ActiveRecord::Relation. Don't know if that is a problem, though.
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.
@ulferts that shouldn't be a problem.
@myabc I am done with my review and once I received statements to my comments, willing to merge this PR. Thanks for the huge amount of work you have put in here! |
…ynamic-finders [20325][20701] Replace dynamic finders, fix ActiveRecord deprecation warnings
💁 This PR doesn't deal with deprecation warnings that are not ActiveRecord related.
Supercedes #3186
https://community.openproject.org/work_packages/20325
https://community.openproject.org/work_packages/20701