forked from Gitlink/forgeplus
Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie
This commit is contained in:
commit
6dcd325031
18
README.md
18
README.md
|
@ -461,31 +461,21 @@ http://localhost:3000/api/projects/migrate | jq
|
|||
"name": "ni项目"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
#### 手动同步镜像
|
||||
```
|
||||
POST api/repositories/:id/sync_mirror
|
||||
```
|
||||
*示例*
|
||||
```
|
||||
curl -X POST \
|
||||
-d "user_id=36401" \
|
||||
http://localhost:3000/api/repositories/1244/sync_mirror | jq
|
||||
curl -X POST http://localhost:3000/api/repositories/1244/sync_mirror | jq
|
||||
```
|
||||
*请求参数说明:*
|
||||
|
||||
|参数名|必选|类型|说明|
|
||||
|-|-|-|-|
|
||||
|user_id |是|int |用户id或者组织id |
|
||||
|name |是|string |项目名称 |
|
||||
|clone_addr |是|string |镜像项目clone地址 |
|
||||
|description |否|string |项目描述 |
|
||||
|repository_name |是|string |仓库名称, 只含有数字、字母、下划线不能以下划线开头和结尾,且唯一 |
|
||||
|project_category_id|是|int |项目类别id |
|
||||
|project_language_id|是|int |项目语言id |
|
||||
|is_mirror |否|boolean|是否设置为镜像, true:是, false:否,默认为否 |
|
||||
|auth_username |否|string|镜像源仓库的登录用户名 |
|
||||
|auth_password |否|string|镜像源仓库的登录秘密 |
|
||||
|private |否|boolean|项目是否私有, true:为私有,false: 非私有,默认为公开 |
|
||||
|id |是|int |仓库id |
|
||||
|
||||
|
||||
*返回参数说明:*
|
||||
|
|
|
@ -208,13 +208,14 @@ class IssuesController < ApplicationController
|
|||
|
||||
if params[:status_id].to_i == 5
|
||||
@issue.issue_times.update_all(end_time: Time.now)
|
||||
@issue.update_closed_issues_count_in_project!
|
||||
end
|
||||
|
||||
if @issue.issue_type.to_s == "2"
|
||||
if @issue.issue_type.to_s == "2"
|
||||
#表示修改token值
|
||||
if @issue.saved_change_to_attribute("token")
|
||||
last_token = @issue.token_was
|
||||
change_token = last_token - @issue.token
|
||||
change_token = last_token - @issue.token
|
||||
change_type = change_token > 0 ? "addToken" : "minusToken"
|
||||
change_params = {
|
||||
change_type: change_type,
|
||||
|
@ -222,7 +223,7 @@ class IssuesController < ApplicationController
|
|||
}.merge(tokens_params(@proeject))
|
||||
ChangeTokenJob.perform_later(change_params)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@issue.create_journal_detail(change_files, issue_files, issue_file_ids, current_user&.id)
|
||||
|
@ -433,6 +434,6 @@ class IssuesController < ApplicationController
|
|||
reponame: project.try(:identifer),
|
||||
username: current_user.try(:login)
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,7 @@ class Issue < ApplicationRecord
|
|||
scope :issue_index_includes, ->{includes(:user,:tracker, :priority, :version, :issue_status, :journals, :issue_times)}
|
||||
|
||||
after_update :change_versions_count
|
||||
after_destroy :update_closed_issues_count_in_project!
|
||||
|
||||
|
||||
def get_assign_user
|
||||
|
@ -102,4 +103,8 @@ class Issue < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def update_closed_issues_count_in_project!
|
||||
self.project.decrement!(:closed_issues_count)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -118,9 +118,6 @@ class Project < ApplicationRecord
|
|||
members.select(:id).size
|
||||
end
|
||||
|
||||
def issues_count
|
||||
issues.select(:id).size
|
||||
end
|
||||
|
||||
def can_visited?
|
||||
is_public? || User.current.admin? || member?(User.current)
|
||||
|
@ -138,4 +135,8 @@ class Project < ApplicationRecord
|
|||
self.pull_requests.select(:user_id).pluck(:user_id).uniq.size
|
||||
end
|
||||
|
||||
def open_issues_count
|
||||
issues_count - closed_issues_count
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -26,5 +26,5 @@ json.array! @entries do |entry|
|
|||
json.content entry['content']
|
||||
json.target entry['target']
|
||||
end
|
||||
json.commit entry['commit']
|
||||
json.commit entry['latest_commit']
|
||||
end
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class AddClosedIssuesCountToProjects < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :projects, :closed_issues_count, :integer, default: 0
|
||||
|
||||
projects = Project.joins(:issues).where('status_id = 5').select("projects.id, count('issues.id') as closed_issues_count").group("projects.id")
|
||||
projects.each do |pro|
|
||||
project = Project.find pro.id
|
||||
project.update_column(:closed_issues_count, pro.closed_issues_count) if project.closed_issues_count == 0
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue