项目动态接口
This commit is contained in:
parent
71c1a0f436
commit
2175e798e1
|
@ -1,6 +1,6 @@
|
|||
class ProjectTrendsController < ApplicationController
|
||||
before_action :load_repository
|
||||
before_action :check_project_public
|
||||
before_action :load_repository, except: [:last]
|
||||
before_action :check_project_public, except: [:last]
|
||||
|
||||
def index
|
||||
project_trends = @project.project_trends.preload(:user, trend: :user, project: :owner)
|
||||
|
@ -42,6 +42,14 @@ class ProjectTrendsController < ApplicationController
|
|||
@project_trends = project_trends.page(@page).per(@limit)
|
||||
end
|
||||
|
||||
def last
|
||||
project_trends = ProjectTrend.preload(:user, trend: :user, project: :owner).order("id desc")
|
||||
@page = params[:page] || 1
|
||||
@limit = params[:limit] || 20
|
||||
@project_trends_count = project_trends.count
|
||||
@project_trends = project_trends.page(@page).per(@limit)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_project_public
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
json.partial! "commons/success"
|
||||
json.total_count @project_trends_count
|
||||
json.project_trends do
|
||||
json.array! @project_trends.to_a.each do |trend|
|
||||
json.partial! "detail", trend: trend
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue