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