-
Notifications
You must be signed in to change notification settings - Fork 22
Organised badge #160
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
base: master
Are you sure you want to change the base?
Organised badge #160
Conversation
DMips
left a comment
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.
Hi,
I reviewed your code - let me know if you have any questions or you want me to implement that!
|
|
||
| private | ||
| def assign_organised_badge(project) | ||
| unless project.mentee.badges.timekeeper.any? |
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.
why?
| namespace :award_badge_once do | ||
| desc "TODO" | ||
| task award_organized_badge: :environment do | ||
| @projects = Project.all |
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.
indentation is weird - standard in ruby is 2 spaces
| @@ -0,0 +1,30 @@ | |||
| namespace :award_badge_once do | |||
| desc "TODO" | |||
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.
TODO? ;)
| @@ -0,0 +1,30 @@ | |||
| namespace :award_badge_once do | |||
| desc "TODO" | |||
| task award_organized_badge: :environment do | |||
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.
how about just organized_badge as award is already in namespace
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.
| desc "TODO" | ||
| task award_organized_badge: :environment do | ||
| @projects = Project.all | ||
| @edition = Edition.last |
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.
you can use Project.current_edition which will return all projects from well this edition so no need to declare @edition variable
| @edition = Edition.last | ||
| @projects.each do |project| | ||
| is_organised_flag = true | ||
| @edition.weeks.each do |week| |
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.
instead of @edition use project.edition
And more importantly I'd rather use query for that. You can add migration to link Week with Task model and then do in project loop:
results = project.tasks.joins(:week).group("weeks.id").count -> will return hash with week_id and number of tasks
results.length == 12 -> award badge
No description provided.