app/models/user.rb
# new feature, get list of available problem in all enabled group that the user belongs to
new feature, get list of available problem in all enabled group that the user belongs to
new feature get list of available problem in all enabled group that the user belongs to
def available_problems_in_group
    problem = []
    self.groups.where(enabled: true).each do |group|
      group.problems.where(available: true).each { |p| problem << p }
    end
    problem.uniq!
    if problem
      problem.sort! do |a,b|
        case
        when a.date_added < b.date_added
          1
        when a.date_added > b.date_added
          -1
        else
          a.name <=> b.name
        end
      end
      return problem
    else
      return []
    end
  end
def available_problems_in_group problem = [ ] self . groups . where ( enabled : true ) . each do | group | group . problems . where ( available : true ) . each { | p | problem << p } end problem . uniq! if problem problem . sort! do | a , b | case when a . date_added < b . date_added 1 when a . date_added > b . date_added - 1 else a . name <=> b . name end end return problem else return [ ] end end
new feature, get list of available problem in all enabled group that the user belongs to
new feature get list of available problem in all enabled group that the user belongs to