Browse Source

Merge branch 'develop' into standalone_develop

pull/313/head
yystopf 3 years ago
parent
commit
a0dcc289c8
5 changed files with 13 additions and 3 deletions
  1. +1
    -1
      app/controllers/api/v1/projects/pulls/journals_controller.rb
  2. +1
    -0
      app/docs/slate/source/includes/_pulls.md
  3. +3
    -1
      app/services/api/v1/projects/pulls/journals/list_service.rb
  4. +1
    -1
      app/views/api/v1/projects/pulls/journals/index.json.jbuilder
  5. +7
    -0
      public/docs/api.html

+ 1
- 1
app/controllers/api/v1/projects/pulls/journals_controller.rb View File

@@ -2,7 +2,7 @@ class Api::V1::Projects::Pulls::JournalsController < Api::V1::Projects::Pulls::B

def index
@journals = Api::V1::Projects::Pulls::Journals::ListService.call(@project, @pull_request, params, current_user)
@journals = kaminari_paginate(@journals)
@journals = @journals.limit(200)
end

def create


+ 1
- 0
app/docs/slate/source/includes/_pulls.md View File

@@ -1248,6 +1248,7 @@ await octokit.request('GET /api/v1/yystopf/ceshi_commit/pulls/3/journals.json')
|need_respond |否| |bool |是否需要回应|
|state |否| |string |状态, opened: 开启的, resolved: 已解决的, disabled: 无效的|
|parent_id |否| |integer|父评论ID|
|path |否| |string |评论文件路径|
|sort_by |否|created_on|string |排序字段 created_on: 创建时间, updated_on: 更新时间|
|sort_direction |否|asc |string |排序类型 desc: 倒序, asc: 正序|



+ 3
- 1
app/services/api/v1/projects/pulls/journals/list_service.rb View File

@@ -1,7 +1,7 @@
class Api::V1::Projects::Pulls::Journals::ListService < ApplicationService
include ActiveModel::Model
attr_reader :project, :pull_request, :keyword, :review_id, :need_respond, :state, :parent_id, :sort_by, :sort_direction, :user
attr_reader :project, :pull_request, :keyword, :review_id, :need_respond, :state, :parent_id, :path, :sort_by, :sort_direction, :user
attr_accessor :queried_journals

validates :sort_by, inclusion: {in: Journal.column_names, message: '请输入正确的SortBy'}
@@ -19,6 +19,7 @@ class Api::V1::Projects::Pulls::Journals::ListService < ApplicationService
@parent_id = params[:parent_id]
@sort_by = params[:sort_by] || 'created_on'
@sort_direction = params[:sort_direction] || 'asc'
@path = params[:path]
@user = user
end

@@ -41,6 +42,7 @@ class Api::V1::Projects::Pulls::Journals::ListService < ApplicationService
journals = journals.where(review_id: review_id) if review_id.present?
journals = journals.where(need_respond: need_respond) if need_respond.present?
journals = journals.where(state: state) if state.present?
journals = journals.where(path: path) if path.present?

q = journals.ransack(notes_cont: keyword)
scope = q.result.includes(:user, :resolveer, review: [:reviewer, pull_request: :issue])


+ 1
- 1
app/views/api/v1/projects/pulls/journals/index.json.jbuilder View File

@@ -1,4 +1,4 @@
json.total_count @journals.total_count
json.total_count @journals.count
json.journals @journals.each do |journal|
json.partial! 'api/v1/projects/pulls/journals/simple_detail', journal: journal
end

+ 7
- 0
public/docs/api.html View File

@@ -15072,6 +15072,13 @@ http://localhost:3000/api/v1/yystopf/ceshi/pulls/1/reviews.json
<td>父评论ID</td>
</tr>
<tr>
<td>path</td>
<td>否</td>
<td></td>
<td>string</td>
<td>评论文件路径</td>
</tr>
<tr>
<td>sort_by</td>
<td>否</td>
<td>created_on</td>


Loading…
Cancel
Save