Skip to content

Add task for set mission to regulated - #291

Open
Floury-Fabio wants to merge 1 commit into
add_controls_for_participations_and_missions_requestsfrom
add_task_for_set_mission_to_regulated
Open

Add task for set mission to regulated#291
Floury-Fabio wants to merge 1 commit into
add_controls_for_participations_and_missions_requestsfrom
add_task_for_set_mission_to_regulated

Conversation

@Floury-Fabio

Copy link
Copy Markdown
Collaborator

it set future mission which are
-name: 'permanence clac'
-genre: 'standard'
-with enrollments are matching timeslots

@Floury-Fabio
Floury-Fabio requested a review from Mate2xo March 22, 2021 17:32
@Floury-Fabio Floury-Fabio self-assigned this Mar 22, 2021
@Floury-Fabio
Floury-Fabio force-pushed the add_task_for_set_mission_to_regulated branch 2 times, most recently from f8b49e8 to cb19536 Compare March 24, 2021 14:04
Comment thread app/admin/enrollments.rb Outdated
Comment thread app/transactions/admin/enrollments/create_transaction.rb Outdated
Comment thread app/transactions/admin/enrollments/create_transaction.rb Outdated
Comment thread app/transactions/admin/enrollments/create_transaction.rb Outdated
def check_member_if_member_is_already_enrolled(input)
mission = input.mission
member = input.member
failure_message = I18n.t('activerecord.errors.models.enrollment.member_already_enrolled')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need a namespace for the transaction object locale, you can go for
'transactions.admin.enrollments.create.the_key_that_you_want' (just follow the folder structure basically)

You could use activerecord locale namespace if you were using these keys elsewhere ; e.g. for model validation feeback

Comment on lines +108 to +119
def match_a_time_slot?(input)
mission = input.mission
return false unless ((input.end_time.to_i - input.start_time.to_i) % (60 * 90)).zero?

current_time_slot = mission.start_date
while current_time_slot < mission.due_date
return true if current_time_slot == input.start_time

current_time_slot += 90.minutes
end
false
end

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this could belong to the Enrollment model?

Comment thread app/transactions/admin/enrollments/create_transaction.rb Outdated
Comment thread app/transactions/admin/enrollments/create_transaction.rb Outdated
Comment thread app/transactions/admin/enrollments/create_transaction.rb Outdated
@Floury-Fabio
Floury-Fabio changed the base branch from development to add_controls_for_participations_and_missions_requests March 25, 2021 11:40
@Floury-Fabio
Floury-Fabio requested a review from Mate2xo March 25, 2021 11:46
it set future mission which are
  -name: 'permanence clac'
  -genre: 'standard'
  -with enrollments are matching timeslots
@Floury-Fabio
Floury-Fabio force-pushed the add_task_for_set_mission_to_regulated branch from cb19536 to 7e373b2 Compare March 29, 2021 06:20

@Mate2xo Mate2xo left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments if you want to improve some wordings.
Also a minor SQL optimization

missions = Mission.where('start_date > ? and genre = ? and name = ?',
DateTime.current + 1.day,
0,
'permanence clac')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think that checking case-insensively could be useful, you can use pgsql's LOWER() method in the .where query string for the name

end
end

def match_all_enrollment_a_time_slot?(mission)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean something like
def all_enrollments_match_a_time_slot?(mission)
?

'permanence clac')
missions.each do |mission|
unless match_all_enrollment_a_time_slot?(mission)
puts("the mission at #{mission.start_date} has not been setted, an enrollment mismatch the mission's timeslots")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

puts("the mission starting at #{mission.start_date} has not been set to the :regulated status : an enrollment doesn't match with the mission's timeslots")

next
end

puts("the mission at #{mission.start_date} has been setted") if mission.update(genre: 1)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...has been set to :regulated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants