Browse Source

fixed CloudIDEA文件标记已读未读列表

pull/313/head
“xxq250” 4 years ago
parent
commit
2b31b683dd
2 changed files with 14 additions and 12 deletions
  1. +7
    -6
      app/controllers/mark_files_controller.rb
  2. +7
    -6
      app/views/mark_files/index.json.jbuilder

+ 7
- 6
app/controllers/mark_files_controller.rb View File

@@ -5,16 +5,17 @@ class MarkFilesController < ApplicationController

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
unless @pull_request.mark_files.present?
MarkFile.bulk_insert(*%i[pull_request_id, file_path_sha file_path created_at updated_at]) do |worker|
@files_result['Files'].each do |file|
worker.add(pull_request_id: @pull_request.id, file_path_sha: SecureRandom.uuid.gsub("-", ""), file_path: file['Name'])
end
end
end
end

private


+ 7
- 6
app/views/mark_files/index.json.jbuilder View File

@@ -1,12 +1,13 @@
json.status 0
json.message 'success'
json.count @mark_files.count
json.count @files_result['NumFiles']
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
json.array! @files_result do |file|
mark_file = @mark_files.select{|mark| mark.file_path.to_s == file['Name']}.first
json.sha Base64.encode64(file.file['Name'].to_s)
json.name file.file['Name']
json.mark_as_read mark_file.present? ? mark_file.mark_as_read : false
# json.updated_after_read mark_file.present? ? mark_file.updated_after_read : false
end

end

Loading…
Cancel
Save