Skip to content

Conversation

@pg20
Copy link
Contributor

@pg20 pg20 commented Oct 25, 2017

No description provided.

Copy link
Contributor

@DMips DMips left a 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?
Copy link
Contributor

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
Copy link
Contributor

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"
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@DMips @pg20 Let's have one rake file for award badges and add all tasks under one namespace for 'award badges'. Should we ?

desc "TODO"
task award_organized_badge: :environment do
@projects = Project.all
@edition = Edition.last
Copy link
Contributor

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|
Copy link
Contributor

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

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.

4 participants