mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-24 13:45:44 +08:00
项目动态接口
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
class ProjectTrendsController < ApplicationController
|
class ProjectTrendsController < ApplicationController
|
||||||
before_action :load_repository
|
before_action :load_repository, except: [:last]
|
||||||
before_action :check_project_public
|
before_action :check_project_public, except: [:last]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
project_trends = @project.project_trends.preload(:user, trend: :user, project: :owner)
|
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)
|
@project_trends = project_trends.page(@page).per(@limit)
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def check_project_public
|
def check_project_public
|
||||||
|
|||||||
8
app/views/project_trends/last.json.jbuilder
Normal file
8
app/views/project_trends/last.json.jbuilder
Normal file
@@ -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
|
||||||
|
|
||||||
Reference in New Issue
Block a user