socialForge#324
This commit is contained in:
parent
ad23ba646e
commit
c38a8e4f6a
|
@ -57,11 +57,16 @@ module WelcomeHelper
|
|||
#
|
||||
# Returns project&courses array
|
||||
def find_miracle_course(sum=10, max_rate=7)
|
||||
max = sum*(max_rate.to_f/10)
|
||||
c1 = find_new_course(sum).to_a.dup
|
||||
c2 = find_all_hot_course(sum).to_a.dup
|
||||
c2 = c2 - c1
|
||||
(c1.take(max)+c2).take(sum)
|
||||
Project.active.visible.course_entities.
|
||||
joins(:course_extra).
|
||||
joins(:memberships).
|
||||
group('members.project_id').
|
||||
reorder("courses.time DESC, COUNT(members.project_id) DESC").take sum
|
||||
# max = sum*(max_rate.to_f/10)
|
||||
# c1 = find_new_course(sum).to_a.dup
|
||||
# c2 = find_all_hot_course(sum).to_a.dup
|
||||
# c2 = c2 - c1
|
||||
# (c1.take(max)+c2).take(sum)
|
||||
end
|
||||
|
||||
def find_miracle_project(sum, max_rate)
|
||||
|
|
|
@ -152,8 +152,8 @@ class Project < ActiveRecord::Base
|
|||
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
||||
end
|
||||
}
|
||||
scope :project_entities, -> { where(project_type: 0) }
|
||||
scope :course_entities, -> { where(project_type: 1) }
|
||||
scope :project_entities, -> { where(project_type: ProjectType_project) }
|
||||
scope :course_entities, -> { where(project_type: ProjectType_course) }
|
||||
|
||||
def new_course
|
||||
self.where('project_type = ?', 1)
|
||||
|
|
Loading…
Reference in New Issue