test
This commit is contained in:
parent
0852d0ac61
commit
59380742a9
4
Gemfile
4
Gemfile
|
@ -64,7 +64,7 @@ end
|
||||||
group :development do
|
group :development do
|
||||||
gem 'prettier'
|
gem 'prettier'
|
||||||
gem 'rubocop', '~> 0.52.0'
|
gem 'rubocop', '~> 0.52.0'
|
||||||
gem 'solargraph', '~> 0.38.0'
|
gem 'solargraph', '~> 0.30.0'
|
||||||
gem 'awesome_print'
|
gem 'awesome_print'
|
||||||
gem 'web-console', '>= 3.3.0'
|
gem 'web-console', '>= 3.3.0'
|
||||||
gem 'listen', '>= 3.0.5', '< 3.2'
|
gem 'listen', '>= 3.0.5', '< 3.2'
|
||||||
|
@ -126,3 +126,5 @@ gem 'request_store'
|
||||||
gem 'harmonious_dictionary', '~> 0.0.1'
|
gem 'harmonious_dictionary', '~> 0.0.1'
|
||||||
|
|
||||||
gem 'parallel', '~> 1.19', '>= 1.19.1'
|
gem 'parallel', '~> 1.19', '>= 1.19.1'
|
||||||
|
#add for debug
|
||||||
|
gem 'thor','~> 0.20.3'
|
||||||
|
|
1004
Gemfile.lock
1004
Gemfile.lock
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,2 @@
|
||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,3 @@
|
||||||
|
// Place all the styles related to the persona controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,128 @@
|
||||||
|
class PersonaController < ApplicationController
|
||||||
|
def show
|
||||||
|
#平台用户总数
|
||||||
|
#@total_users_count = User.count
|
||||||
|
#平台被Foller数量
|
||||||
|
#@total_follow_count = Watcher.count
|
||||||
|
#平台总项目数
|
||||||
|
#@total_project_count = Project.count
|
||||||
|
#平台不同语言项目数量
|
||||||
|
#@total_project_languages_count = Project.joins(:project_language).group("project_languages.name").count
|
||||||
|
# 平台不同种类项目数量
|
||||||
|
#@total_project_category_count = Project.joins(:project_category).group("project_categories.name").count
|
||||||
|
# 平台用户被fork数量
|
||||||
|
#@total_fork_count = Project.sum('forked_count')
|
||||||
|
#平台所有项目关注数
|
||||||
|
#@total_project_watchers_count = Project.sum('watchers_count')
|
||||||
|
#平台所有项目点赞数
|
||||||
|
#@total_project_praises_count = Project.sum('praises_count')
|
||||||
|
#平台所有项目下的Issue数量
|
||||||
|
#@total_project_issues_count = Project.sum('issues_count')
|
||||||
|
#平台所有PR数量
|
||||||
|
#@total_pullrequest_count = PullRequest.count
|
||||||
|
|
||||||
|
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
||||||
|
#用户被Foller数量
|
||||||
|
@follow_count = Watcher.where(watchable_id:@user.id).count
|
||||||
|
#三个月(90d)Foller数量
|
||||||
|
@recent_follow_count = Watcher.where(watchable_id:@user.id,created_at: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
#用户总项目数
|
||||||
|
@project_count = Project.where(user_id:@user.id).count
|
||||||
|
#用户三个月(90d)总项目数
|
||||||
|
@recent_project_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
# 用户不同语言项目数量
|
||||||
|
@project_languages_count = Project.where(user_id:@user.id).joins(:project_language).group("project_languages.name").count
|
||||||
|
#三个月(90d)不同语言项目数量
|
||||||
|
@recent_project_languages_count = Project.where(user_id:@user.id).joins(:project_language).group("project_languages.name").where(created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
# 用户不同种类项目数量
|
||||||
|
@project_category_count = Project.where(user_id:@user.id).joins(:project_category).group("project_categories.name").count
|
||||||
|
# 三个月(90d)不同种类项目数量
|
||||||
|
@recent_project_category_count = Project.where(user_id:@user.id).joins(:project_category).group("project_categories.name").where(created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
# 用户被fork数量
|
||||||
|
@fork_count = Project.where(user_id:@user.id).sum('forked_count')
|
||||||
|
# 三个月(90d)用户被fork数量
|
||||||
|
@recent_fork_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).sum('forked_count')
|
||||||
|
|
||||||
|
#用户所有项目关注数
|
||||||
|
@project_watchers_count = Project.where(user_id:@user.id).sum('watchers_count')
|
||||||
|
#三个月(90d)用户所有项目关注数
|
||||||
|
@recent_project_watchers_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).sum('watchers_count')
|
||||||
|
|
||||||
|
#用户所有项目点赞数
|
||||||
|
@project_praises_count = Project.where(user_id:@user.id).sum('praises_count')
|
||||||
|
#三个月(90d)用户所有项目点赞数
|
||||||
|
@recent_project_praises_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).sum('praises_count')
|
||||||
|
|
||||||
|
#用户所有项目下的Issue数量
|
||||||
|
@project_issues_count = Project.where(user_id:@user.id).sum('issues_count')
|
||||||
|
#三个月(90d)用户所有项目下的Issue数量
|
||||||
|
@recent_project_issues_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).sum('issues_count')
|
||||||
|
|
||||||
|
#用户创建的总Issue数量
|
||||||
|
@issues_count = Issue.where(author_id:@user.id).count
|
||||||
|
#三个月(90d)用户创建的总Issue数量
|
||||||
|
@recent_issues_count = Issue.where(author_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
#用户总PR数量
|
||||||
|
@pullrequest_count = PullRequest.where(user_id:@user.id).count
|
||||||
|
#三个月(90d)用户总PR数量
|
||||||
|
@recent_pullrequest_count = PullRequest.where(user_id:@user.id).count
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#####用户画像展示数据#####
|
||||||
|
#影响力
|
||||||
|
@influence = (60.0 + @follow_count / (@follow_count + 20.0) * 40.0).to_i
|
||||||
|
#@recent_influence = (60.0 + @recent_follow_count / (@recent_follow_count + 10.0) * 40.0).to_i
|
||||||
|
|
||||||
|
#贡献度
|
||||||
|
@contribution = (60.0 + @pullrequest_count / (@pullrequest_count + 20.0) * 40.0).to_i
|
||||||
|
@recent_contribution = (60.0 + @recent_pullrequest_count / (@recent_pullrequest_count + 10.0) * 40.0).to_i
|
||||||
|
|
||||||
|
#活跃度
|
||||||
|
@activity = (60.0 + @issues_count / (@issues_count + 80.0) * 40.0).to_i
|
||||||
|
@recent_activity = (60.0 + @recent_issues_count / (@recent_issues_count + 10.0) * 40.0).to_i
|
||||||
|
|
||||||
|
#项目经验
|
||||||
|
@experience = 10 * @project_count + 5 * @fork_count + @project_watchers_count + @project_praises_count
|
||||||
|
@experience = (60.0 + @experience / (@experience + 100.0) * 40.0).to_i
|
||||||
|
@recent_experience = 10 * @recent_project_count + 5 * @recent_fork_count + @recent_project_watchers_count + @recent_project_praises_count
|
||||||
|
@recent_experience = (60.0 + @recent_experience / (@recent_experience + 100.0) * 40.0).to_i
|
||||||
|
|
||||||
|
#语言能力
|
||||||
|
@language = (60.0 + @project_languages_count.length / (@project_languages_count.length + 5.0) * 40.0).to_i
|
||||||
|
@recent_language = (60.0 + @recent_project_languages_count.length / (@recent_project_languages_count.length + 5.0) * 40.0).to_i
|
||||||
|
|
||||||
|
#词云图数据
|
||||||
|
@project_category_count
|
||||||
|
@recent_project_category_count
|
||||||
|
|
||||||
|
|
||||||
|
#语言百分比
|
||||||
|
@languages_percent = Hash.new
|
||||||
|
for key in @project_languages_count.keys do
|
||||||
|
@languages_percent[key] = @project_languages_count[key].to_f / @project_languages_count.values.sum
|
||||||
|
end
|
||||||
|
@recent_languages_percent = Hash.new
|
||||||
|
for key in @recent_project_languages_count.keys do
|
||||||
|
@recent_languages_percent[key] = @recent_project_languages_count[key].to_f / @recent_project_languages_count.values.sum
|
||||||
|
end
|
||||||
|
|
||||||
|
#各门语言分数
|
||||||
|
@each_language_score = Hash.new
|
||||||
|
for key in @project_languages_count.keys do
|
||||||
|
@each_language_score[key] = (60.0 + @project_languages_count[key] / (@project_languages_count[key] + 5.0) * 40.0).to_i
|
||||||
|
end
|
||||||
|
@recent_each_language_score = Hash.new
|
||||||
|
for key in @recent_project_languages_count.keys do
|
||||||
|
@recent_each_language_score[key] = (60.0 + @recent_project_languages_count[key] / (@recent_project_languages_count[key] + 5.0) * 40.0).to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -55,7 +55,82 @@ class UsersController < ApplicationController
|
||||||
@watchers_count = watchers.size
|
@watchers_count = watchers.size
|
||||||
@watchers = paginate(watchers)
|
@watchers = paginate(watchers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#def persona
|
||||||
|
#平台用户总数
|
||||||
|
#@total_users_count = User.count
|
||||||
|
#平台被Foller数量
|
||||||
|
#@total_follow_count = Watcher.count
|
||||||
|
#平台总项目数
|
||||||
|
#@total_project_count = Project.count
|
||||||
|
#平台不同语言项目数量
|
||||||
|
#@total_project_languages_count = Project.joins(:project_language).group("project_languages.name").count
|
||||||
|
# 平台不同种类项目数量
|
||||||
|
#@total_project_category_count = Project.joins(:project_category).group("project_categories.name").count
|
||||||
|
# 平台用户被fork数量
|
||||||
|
#@total_fork_count = Project.sum('forked_count')
|
||||||
|
#平台所有项目关注数
|
||||||
|
#@total_project_watchers_count = Project.sum('watchers_count')
|
||||||
|
#平台所有项目点赞数
|
||||||
|
#@total_project_praises_count = Project.sum('praises_count')
|
||||||
|
#平台所有项目下的Issue数量
|
||||||
|
#@total_project_issues_count = Project.sum('issues_count')
|
||||||
|
#平台所有PR数量
|
||||||
|
#@total_pullrequest_count = PullRequest.count
|
||||||
|
|
||||||
|
|
||||||
|
#用户被Foller数量
|
||||||
|
#@follow_count = watchers.where(watchable_id:@user.id).count
|
||||||
|
#三个月(90d)Foller数量
|
||||||
|
#@recent_follow_count = watchers.where(watchable_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
#用户总项目数
|
||||||
|
#@project_count = Project.where(user_id:@user.id).count
|
||||||
|
#用户三个月(90d)总项目数
|
||||||
|
#@recent_project_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
# 用户不同语言项目数量
|
||||||
|
#@project_languages_count = Project.where(user_id:@user.id).joins(:project_language).group("project_languages.name").count
|
||||||
|
#三个月(90d)不同语言项目数量
|
||||||
|
#@recent_project_languages_count = Project.where(user_id:@user.id).joins(:project_language).group("project_languages.name").where(created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
# 用户不同种类项目数量
|
||||||
|
#@project_category_count = Project.where(user_id:@user.id).joins(:project_category).group("project_categories.name").count
|
||||||
|
# 三个月(90d)不同种类项目数量
|
||||||
|
#@recent_project_category_count = Project.where(user_id:@user.id).joins(:project_category).group("project_categories.name").where(created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
# 用户被fork数量
|
||||||
|
#@fork_count = Project.where(user_id:@user.id).sum('forked_count')
|
||||||
|
# 三个月(90d)用户被fork数量
|
||||||
|
#@recent_fork_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).sum('forked_count')
|
||||||
|
|
||||||
|
#用户所有项目关注数
|
||||||
|
#@project_watchers_count = Project.where(user_id:@user.id).sum('watchers_count')
|
||||||
|
#三个月(90d)用户所有项目关注数
|
||||||
|
#@recent_project_watchers_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight)).sum('watchers_count')
|
||||||
|
|
||||||
|
#用户所有项目点赞数
|
||||||
|
#@project_praises_count = Project.where(user_id:@user.id).sum('praises_count')
|
||||||
|
#三个月(90d)用户所有项目点赞数
|
||||||
|
#@recent_project_praises_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight)).sum('praises_count')
|
||||||
|
|
||||||
|
#用户所有项目下的Issue数量
|
||||||
|
#@project_issues_count = Project.where(user_id:@user.id).sum('issues_count')
|
||||||
|
#三个月(90d)用户所有项目下的Issue数量
|
||||||
|
#@recent_project_issues_count = Project.where(user_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight)).sum('issues_count')
|
||||||
|
|
||||||
|
#用户创建的总Issue数量
|
||||||
|
#@issues_count = Issue.where(author_id:@user.id).count
|
||||||
|
#三个月(90d)用户创建的总Issue数量
|
||||||
|
#@recent_issues_count = Issue.where(author_id:@user.id,created_on: (Time.now.midnight - 90.day)..Time.now.midnight).count
|
||||||
|
|
||||||
|
#用户总PR数量
|
||||||
|
#@pullrequest_count = PullRequest.where(user_id:@user.id).count
|
||||||
|
#三个月(90d)用户总PR数量
|
||||||
|
#@recent_pullrequest_count = PullRequest.where(user_id:@user.id).count
|
||||||
|
|
||||||
|
#end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@user = User.find params[:id]
|
@user = User.find params[:id]
|
||||||
@user.update!(user_params)
|
@user.update!(user_params)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
module PersonaHelper
|
||||||
|
end
|
|
@ -0,0 +1,18 @@
|
||||||
|
<h1> 影响力 <%=@influence %> </h1>
|
||||||
|
<h1> 近期影响力 <%=@recent_influence %> </h1>
|
||||||
|
<h1> 贡献度 <%=@contribution %> </h1>
|
||||||
|
<h1> 近期贡献度 <%=@recent_contribution %> </h1>
|
||||||
|
<h1> 活跃度 <%=@activity %> </h1>
|
||||||
|
<h1> 近期活跃度 <%=@recent_activity %> </h1>
|
||||||
|
<h1> 项目经验 <%=@experience %> </h1>
|
||||||
|
<h1> 近期项目经验 <%=@recent_experience %> </h1>
|
||||||
|
<h1> 语言能力 <%=@language %> </h1>
|
||||||
|
<h1> 近期语言能力 <%=@recent_language %> </h1>
|
||||||
|
|
||||||
|
<h1> 词云图数据 <%=@project_category_count %> </h1>
|
||||||
|
<h1> 近期词云图数据 <%=@recent_project_category_count %> </h1>
|
||||||
|
<h1> 语言百分比 <%=@languages_percent %> </h1>
|
||||||
|
<h1> 近期语言百分比 <%=@recent_languages_percent %> </h1>
|
||||||
|
<h1> 各门语言分数 <%=@each_language_score %> </h1>
|
||||||
|
<h1> 近期各门语言分数 <%=@recent_each_language_score %> </h1>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<%= @contents.html_safe %>
|
<%= @contents.html_safe %>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
|
get 'persona/show/:id', to:'persona#show'
|
||||||
require 'sidekiq/web'
|
require 'sidekiq/web'
|
||||||
require 'sidekiq/cron/web'
|
require 'sidekiq/cron/web'
|
||||||
require 'admin_constraint'
|
require 'admin_constraint'
|
||||||
|
@ -20,7 +21,7 @@ Rails.application.routes.draw do
|
||||||
get 'oauth/bind', to: 'oauth/educoder#bind'
|
get 'oauth/bind', to: 'oauth/educoder#bind'
|
||||||
get 'oauth/register', to: 'oauth#register'
|
get 'oauth/register', to: 'oauth#register'
|
||||||
post 'oauth/auto_register', to: 'oauth#auto_register'
|
post 'oauth/auto_register', to: 'oauth#auto_register'
|
||||||
|
|
||||||
resources :edu_settings
|
resources :edu_settings
|
||||||
|
|
||||||
scope '/api' do
|
scope '/api' do
|
||||||
|
@ -198,6 +199,7 @@ Rails.application.routes.draw do
|
||||||
get :projects
|
get :projects
|
||||||
get :watch_users
|
get :watch_users
|
||||||
get :fan_users
|
get :fan_users
|
||||||
|
#get :persona, :to => 'users#persona'
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
post :following
|
post :following
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe PersonaController, type: :controller do
|
||||||
|
|
||||||
|
describe "GET #show" do
|
||||||
|
it "returns http success" do
|
||||||
|
get :show
|
||||||
|
expect(response).to have_http_status(:success)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the PersonaHelper. For example:
|
||||||
|
#
|
||||||
|
# describe PersonaHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
RSpec.describe PersonaHelper, type: :helper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "persona/show.html.erb", type: :view do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue