Merge branch 'pre_trustie_server' into trustie_server
This commit is contained in:
commit
7b64813471
|
@ -19,9 +19,10 @@ class CommitLogsController < ApplicationController
|
||||||
params[:commits].each do |commit|
|
params[:commits].each do |commit|
|
||||||
commit_id = commit[:id]
|
commit_id = commit[:id]
|
||||||
message = commit[:message]
|
message = commit[:message]
|
||||||
CommitLog.create(user: user, project: project, repository_id: repository_id,
|
commit_log = CommitLog.create(user: user, project: project, repository_id: repository_id,
|
||||||
name: repository_name, full_name: repository_full_name,
|
name: repository_name, full_name: repository_full_name,
|
||||||
ref: ref, commit_id: commit_id, message: message)
|
ref: ref, commit_id: commit_id, message: message)
|
||||||
|
commit_log.project_trends.create(user_id: user.id, project_id: project&.id, action_type: "create")
|
||||||
# 统计数据新增
|
# 统计数据新增
|
||||||
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)
|
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -3,4 +3,10 @@ class CommitLog < ApplicationRecord
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :repository
|
belongs_to :repository
|
||||||
|
|
||||||
|
has_many :project_trends, as: :trend, dependent: :destroy
|
||||||
|
|
||||||
|
def title
|
||||||
|
self.message
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,15 @@ if trend.trend_type == "Issue"
|
||||||
json.partial! "issues/simple_issue_item", locals: {issue: trend.trend}
|
json.partial! "issues/simple_issue_item", locals: {issue: trend.trend}
|
||||||
elsif trend.trend_type == "VersionRelease"
|
elsif trend.trend_type == "VersionRelease"
|
||||||
json.partial! "version_releases/simple_version_release", locals: {version: trend.trend}
|
json.partial! "version_releases/simple_version_release", locals: {version: trend.trend}
|
||||||
|
elsif trend.trend_type == "CommitLog"
|
||||||
|
json.commit_log do
|
||||||
|
commit_log = trend.trend
|
||||||
|
json.user do
|
||||||
|
json.partial! 'users/user_simple', locals: {user: commit_log.user}
|
||||||
|
end
|
||||||
|
json.ref commit_log.ref.to_s.gsub("refs/heads/", "")
|
||||||
|
json.extract! commit_log, :id,:name,:full_name,:message, :commit_id,:created_at,:updated_at
|
||||||
|
end
|
||||||
else
|
else
|
||||||
json.name trend.trend&.title
|
json.name trend.trend&.title
|
||||||
json.created_at format_time(trend.trend&.created_at)
|
json.created_at format_time(trend.trend&.created_at)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -18,6 +18,7 @@ zh-CN:
|
||||||
Issue: 疑修(Issue)
|
Issue: 疑修(Issue)
|
||||||
PullRequest: 合并请求(PR)
|
PullRequest: 合并请求(PR)
|
||||||
VersionRelease: 版本发布
|
VersionRelease: 版本发布
|
||||||
|
CommitLog: 代码(Commit)
|
||||||
create: 创建了
|
create: 创建了
|
||||||
journal: 回复了
|
journal: 回复了
|
||||||
close: 关闭了
|
close: 关闭了
|
||||||
|
|
|
@ -117,6 +117,7 @@ Rails.application.routes.draw do
|
||||||
get 'home/index'
|
get 'home/index'
|
||||||
get 'home/search'
|
get 'home/search'
|
||||||
get 'main/first_stamp'
|
get 'main/first_stamp'
|
||||||
|
get 'activity/last', to: 'project_trends#last'
|
||||||
|
|
||||||
get 'search', to: 'searchs#index'
|
get 'search', to: 'searchs#index'
|
||||||
put 'commons/hidden', to: 'commons#hidden'
|
put 'commons/hidden', to: 'commons#hidden'
|
||||||
|
@ -763,6 +764,7 @@ Rails.application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Project Area END
|
# Project Area END
|
||||||
|
|
||||||
scope module: :helps do
|
scope module: :helps do
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class UpdateCommitLogUtf8 < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
execute("ALTER TABLE `commit_logs` MODIFY `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
|
||||||
|
execute("ALTER TABLE `commit_logs` MODIFY `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue