From 2b31b683ddee9b9e4c571461c1eabbaa4fef5323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Thu, 28 Jul 2022 17:53:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fixed=20CloudIDEA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=B7=B2=E8=AF=BB=E6=9C=AA=E8=AF=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/mark_files_controller.rb | 13 +++++++------ app/views/mark_files/index.json.jbuilder | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/controllers/mark_files_controller.rb b/app/controllers/mark_files_controller.rb index 88856c35a..53bd279e7 100644 --- a/app/controllers/mark_files_controller.rb +++ b/app/controllers/mark_files_controller.rb @@ -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 diff --git a/app/views/mark_files/index.json.jbuilder b/app/views/mark_files/index.json.jbuilder index 18bf90b5d..ae422c91f 100644 --- a/app/views/mark_files/index.json.jbuilder +++ b/app/views/mark_files/index.json.jbuilder @@ -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 From 487c6dc21a00766982951b65ff167be417312b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Thu, 28 Jul 2022 17:55:31 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fixed=20CloudIDEA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=B7=B2=E8=AF=BB=E6=9C=AA=E8=AF=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mark_files/index.json.jbuilder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/mark_files/index.json.jbuilder b/app/views/mark_files/index.json.jbuilder index ae422c91f..ab50c251e 100644 --- a/app/views/mark_files/index.json.jbuilder +++ b/app/views/mark_files/index.json.jbuilder @@ -4,8 +4,8 @@ json.count @files_result['NumFiles'] json.files do 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.sha Base64.encode64(file['Name'].to_s) + json.name 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 From 93fd9333ecbeb28dee3247e19d62b7e9b927b448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Thu, 28 Jul 2022 17:56:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fixed=20CloudIDEA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=B7=B2=E8=AF=BB=E6=9C=AA=E8=AF=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mark_files/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/mark_files/index.json.jbuilder b/app/views/mark_files/index.json.jbuilder index ab50c251e..d3c080134 100644 --- a/app/views/mark_files/index.json.jbuilder +++ b/app/views/mark_files/index.json.jbuilder @@ -2,7 +2,7 @@ json.status 0 json.message 'success' json.count @files_result['NumFiles'] json.files do - json.array! @files_result do |file| + json.array! @files_result['Files'] do |file| mark_file = @mark_files.select{|mark| mark.file_path.to_s == file['Name']}.first json.sha Base64.encode64(file['Name'].to_s) json.name file['Name'] From 8a187df5f414f79c2bf4f31cef2e1908a43bed6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Thu, 28 Jul 2022 17:59:20 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fixed=20CloudIDEA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=B7=B2=E8=AF=BB=E6=9C=AA=E8=AF=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mark_files/index.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/mark_files/index.json.jbuilder b/app/views/mark_files/index.json.jbuilder index d3c080134..709be77b8 100644 --- a/app/views/mark_files/index.json.jbuilder +++ b/app/views/mark_files/index.json.jbuilder @@ -4,7 +4,7 @@ json.count @files_result['NumFiles'] json.files do json.array! @files_result['Files'] do |file| mark_file = @mark_files.select{|mark| mark.file_path.to_s == file['Name']}.first - json.sha Base64.encode64(file['Name'].to_s) + json.file_path_sha Base64.strict_encode64(file['Name'].to_s) json.name 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