From b8869bd0e2dc78bdef742592516cc773c8cc678f Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 28 Mar 2023 14:48:11 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=9A=E8=B4=A1?= =?UTF-8?q?=E7=8C=AE=E8=80=85=E8=B4=A1=E7=8C=AE=E5=8D=A0=E6=AF=94=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/concerns/watchable.rb | 20 +++++++++++++++++++ .../repositories/_contributor.json.jbuilder | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/watchable.rb b/app/models/concerns/watchable.rb index dc2b67f67..31093cad1 100644 --- a/app/models/concerns/watchable.rb +++ b/app/models/concerns/watchable.rb @@ -31,6 +31,26 @@ module Watchable following.size end + def simple_contribution_perc(project, perc=nil) + @project = project + @user = self + + def cal_perc(count_user, count_all) + (count_user * 1.0 / (count_all + 0.000000001)).round(5) + end + + if (@project['use_blockchain'] == true or @project['use_blockchain'] == 1) && @user.id.present? + balance_user = Blockchain::BalanceQueryOneProject.call({"user_id": @user.id, "project_id": @project.id}) + balance_all = Blockchain::RepoBasicInfo.call({"project_id": @project.id})["cur_supply"] + score = cal_perc(balance_user, balance_all) + score = (score * 100).round(1).to_s + "%" + else + score = perc + end + + score + end + def contribution_perc(project) @project = project @user = self diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index bd1a037f7..41edbf4af 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -6,6 +6,7 @@ if user.blank? json.type nil json.name contributor["login"] json.image_url User::Avatar.get_letter_avatar_url(contributor["login"]) + json.contribution_perc User.new(login: contributor["login"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"]) else json.contributions contributor["contributions"] # json.gid contributor["id"] @@ -14,5 +15,5 @@ else json.name user["name"] json.image_url user["avatar_url"] db_user = User.find_by_id(user["id"]) - json.contribution_perc db_user.contribution_perc(project) if db_user.present? + json.contribution_perc db_user.simple_contribution_perc(project) if db_user.present? end From 33e503ed9a72aa0538628a206e2fbbbcdf2cd036 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 28 Mar 2023 14:57:35 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_contributor.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index 41edbf4af..49ec699bc 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -15,5 +15,5 @@ else json.name user["name"] json.image_url user["avatar_url"] db_user = User.find_by_id(user["id"]) - json.contribution_perc db_user.simple_contribution_perc(project) if db_user.present? + json.contribution_perc db_user.simple_contribution_perc(project, contributor["contribution_perc"]) if db_user.present? end From 7e0158345c82abd3041e88abbf92b84db48b552d Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 28 Mar 2023 15:00:37 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_contributor.json.jbuilder | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index 49ec699bc..bbfa08262 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -1,12 +1,12 @@ -user = $redis_cache.hgetall("v2-owner-common:#{contributor["login"]}-#{contributor["email"]}") +user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"]}-#{contributor["email"]}") if user.blank? json.contributions contributor["contributions"] # json.gid contributor["id"] - json.login contributor["login"] + json.login contributor["name"] json.type nil - json.name contributor["login"] - json.image_url User::Avatar.get_letter_avatar_url(contributor["login"]) - json.contribution_perc User.new(login: contributor["login"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"]) + json.name contributor["name"] + json.image_url User::Avatar.get_letter_avatar_url(contributor["name"]) + json.contribution_perc User.new(login: contributor["name"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"]) else json.contributions contributor["contributions"] # json.gid contributor["id"] From 6a6a257d2a51169150be5ccdd11fe05a473b21c8 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 28 Mar 2023 15:03:13 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E8=B4=A1=E7=8C=AE?= =?UTF-8?q?=E8=80=85=E5=A4=A7=E5=B0=8F=E5=86=99=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_contributor.json.jbuilder | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index bbfa08262..fa5151264 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -2,17 +2,17 @@ user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"]}-#{contributo if user.blank? json.contributions contributor["contributions"] # json.gid contributor["id"] - json.login contributor["name"] + json.login contributor["name"].downcase json.type nil - json.name contributor["name"] + json.name contributor["name"].downcase json.image_url User::Avatar.get_letter_avatar_url(contributor["name"]) json.contribution_perc User.new(login: contributor["name"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"]) else json.contributions contributor["contributions"] # json.gid contributor["id"] - json.login user["login"] + json.login user["login"].downcase json.type user["type"] - json.name user["name"] + json.name user["name"].downcase json.image_url user["avatar_url"] db_user = User.find_by_id(user["id"]) json.contribution_perc db_user.simple_contribution_perc(project, contributor["contribution_perc"]) if db_user.present? From 6992bf4959955271fba2d174a277ed91ce59b479 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 28 Mar 2023 15:15:08 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E8=B4=A1=E7=8C=AE=E8=80=85=E8=AF=BB=E5=8F=96=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_contributor.json.jbuilder | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/repositories/_contributor.json.jbuilder b/app/views/repositories/_contributor.json.jbuilder index fa5151264..4a8f5611d 100644 --- a/app/views/repositories/_contributor.json.jbuilder +++ b/app/views/repositories/_contributor.json.jbuilder @@ -1,14 +1,16 @@ user = $redis_cache.hgetall("v2-owner-common:#{contributor["name"]}-#{contributor["email"]}") if user.blank? - json.contributions contributor["contributions"] + json.contributions contributor["commits"] # json.gid contributor["id"] - json.login contributor["name"].downcase + json.login nil json.type nil json.name contributor["name"].downcase + json.email contributor["email"] json.image_url User::Avatar.get_letter_avatar_url(contributor["name"]) json.contribution_perc User.new(login: contributor["name"], mail: contributor["email"]).simple_contribution_perc(project, contributor["contribution_perc"]) else - json.contributions contributor["contributions"] + json.contributions contributor["commits"] + json.id user["id"] # json.gid contributor["id"] json.login user["login"].downcase json.type user["type"] From 4bf14974dfb212aa7a6fb4f3d81477cc16574b11 Mon Sep 17 00:00:00 2001 From: yystopf Date: Tue, 28 Mar 2023 15:51:51 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=98=AF=E5=90=A6=E5=88=9B=E5=BB=BA=E4=BA=86pr?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/pull_requests/index.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/pull_requests/index.json.jbuilder b/app/views/pull_requests/index.json.jbuilder index ace52945c..299db0283 100644 --- a/app/views/pull_requests/index.json.jbuilder +++ b/app/views/pull_requests/index.json.jbuilder @@ -9,6 +9,7 @@ json.user_admin_or_developer @user_admin_or_developer json.project_name @project.name json.project_author @project.owner.try(:login) json.project_author_name @project.owner.try(:show_real_name) +json.has_created_pull_requests @project.pull_requests.size > 0 json.issues do json.array! @issues.to_a do |issue|