CloudIDEA文件标记已读未读
This commit is contained in:
parent
79a6841bbc
commit
4ccf8ea5ff
|
@ -0,0 +1,29 @@
|
|||
class MarkFilesController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :load_project
|
||||
before_action :load_pull_request
|
||||
|
||||
def index
|
||||
@files_result = Gitea::PullRequest::FilesService.call(@owner.login, @project.identifier, @pull_request.gitea_number, current_user&.gitea_token)
|
||||
|
||||
MarkFile.bulk_insert(*%i[pull_request_id, file_path_sha file_path created_at updated_at]) do |worker|
|
||||
@files_result['Files'].echo do |file|
|
||||
worker.add(pull_request_id: @pull_request.id, file_path_sha: SecureRandom.uuid.gsub("-", ""), file_path: file['Name'])
|
||||
end
|
||||
end
|
||||
@mark_files = MarkFile.where(pull_request_id: @pull_request.id)
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
private
|
||||
def review_params
|
||||
params.require(:review).permit(:content, :commit_id, :status)
|
||||
end
|
||||
|
||||
def load_pull_request
|
||||
@pull_request = @project.pull_requests.where(gitea_number: params[:id]).where.not(id: params[:id]).take || PullRequest.find_by_id(params[:id])
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class MarkFile < ApplicationRecord
|
||||
belongs_to :pull_request
|
||||
|
||||
|
||||
end
|
|
@ -43,6 +43,7 @@ class PullRequest < ApplicationRecord
|
|||
has_many :reviews, dependent: :destroy
|
||||
has_many :pull_requests_reviewers, dependent: :destroy
|
||||
has_many :reviewers, through: :pull_requests_reviewers
|
||||
has_many :mark_files, dependent: :destroy
|
||||
|
||||
scope :merged_and_closed, ->{where.not(status: 0)}
|
||||
scope :opening, -> {where(status: 0)}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
json.status 0
|
||||
json.message 'success'
|
||||
json.count @mark_files.count
|
||||
json.files do
|
||||
json.array! @mark_files do |file|
|
||||
json.sha file.file_path_sha
|
||||
json.name file.file_path
|
||||
json.mark_as_read file.mark_as_read
|
||||
json.updated_after_read file.updated_after_read
|
||||
end
|
||||
|
||||
end
|
|
@ -528,7 +528,8 @@ Rails.application.routes.draw do
|
|||
post :refuse_merge
|
||||
get :files
|
||||
get :commits
|
||||
resources :reviews, only: [:create]
|
||||
resources :reviews, only: [:create]
|
||||
resources :mark_files, only: [:index, :create]
|
||||
end
|
||||
collection do
|
||||
post :check_can_merge
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class CreateMarkFiles < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :mark_files do |t|
|
||||
t.references :pull_request
|
||||
t.integer :user_id
|
||||
t.string :file_path_sha
|
||||
t.string :file_path
|
||||
t.boolean :mark_as_read, default: false
|
||||
t.boolean :updated_after_read, default: false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :mark_files, :file_path_sha
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue