forked from Gitlink/forgeplus
Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
d76d85b8fb | |
|
82907e001f | |
|
b8f9deb1ed |
|
@ -124,6 +124,7 @@ class AccountsController < ApplicationController
|
|||
password = register_params[:password].strip
|
||||
|
||||
# gitea用户注册, email, username, password
|
||||
|
||||
interactor = Gitea::RegisterInteractor.call({username: user.login, email: user.mail, password: password})
|
||||
if interactor.success?
|
||||
gitea_user = interactor.result
|
||||
|
@ -138,6 +139,7 @@ class AccountsController < ApplicationController
|
|||
else
|
||||
tip_exception(-1, interactor.error)
|
||||
end
|
||||
|
||||
rescue Register::BaseForm::EmailError => e
|
||||
render_error(-2, e.message)
|
||||
rescue Register::BaseForm::LoginError => e
|
||||
|
|
|
@ -265,9 +265,9 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
# if !User.current.logged? && Rails.env.development?
|
||||
# User.current = User.find 1
|
||||
# end
|
||||
if !User.current.logged? && Rails.env.development?
|
||||
User.current = User.find 104
|
||||
end
|
||||
|
||||
|
||||
# 测试版前端需求
|
||||
|
|
|
@ -14,6 +14,22 @@ class Organizations::ProjectsController < Organizations::BaseController
|
|||
@projects = paginate(@projects)
|
||||
end
|
||||
|
||||
#######################change#################################
|
||||
def organizationBadge
|
||||
watchers_count = @organization.watchers_count
|
||||
|
||||
@watchered = judge_level(watchers_count, 10, 20, 100)
|
||||
|
||||
@badge = organizationBadge.find_or_create_by(organization_id: @organization.id)
|
||||
|
||||
if @watchered != @badge.watched
|
||||
@badge.watched = @watchered
|
||||
@badge.save
|
||||
end
|
||||
render :json => {list: [{watchered: @watchered}], count: 1}
|
||||
end
|
||||
#######################change#################################
|
||||
|
||||
def search
|
||||
tip_exception("请输入搜索关键词") if params[:search].nil?
|
||||
public_projects_sql = @organization.projects.where(is_public: true).to_sql
|
||||
|
@ -42,4 +58,17 @@ class Organizations::ProjectsController < Organizations::BaseController
|
|||
def sort_direction
|
||||
%w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
|
||||
end
|
||||
|
||||
|
||||
def judge_level(judged, low, mid, high)
|
||||
if judged < low
|
||||
return 0
|
||||
elsif judged < mid
|
||||
return 1
|
||||
elsif judged < high
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
end
|
||||
end
|
||||
end
|
|
@ -6,7 +6,6 @@ class Organizations::TeamProjectsController < Organizations::BaseController
|
|||
|
||||
def index
|
||||
@team_projects = @team.team_projects
|
||||
|
||||
@team_projects = paginate(@team_projects)
|
||||
end
|
||||
|
||||
|
|
|
@ -12,12 +12,58 @@ class RepositoriesController < ApplicationController
|
|||
before_action :get_ref, only: %i[entries sub_entries top_counts file archive]
|
||||
before_action :get_latest_commit, only: %i[entries sub_entries top_counts]
|
||||
before_action :get_statistics, only: %i[top_counts]
|
||||
before_action :preload_badge, only: [:badges]
|
||||
|
||||
def files
|
||||
result = @project.educoder? ? nil : Gitea::Repository::Files::GetService.call(@owner, @project.identifier, @ref, params[:search], @owner.gitea_token)
|
||||
render json: result
|
||||
end
|
||||
|
||||
|
||||
def preload_badge
|
||||
@praised_cache = "praised"
|
||||
@forked_cache = "forked"
|
||||
@watchered_cache = "watchered"
|
||||
@badge = RepositoryBadge.find_or_create_by(user_id: observed_user.id)
|
||||
$redis_cache.hset(project_statistic_key, @many_projects_cache, @badge.many_projects)
|
||||
$redis_cache.hset(project_statistic_key, @manyParisesProject_cache, @badge.manyParisesProject)
|
||||
$redis_cache.hset(project_statistic_key, @parises_project_cache, @badge.parises_project)
|
||||
end
|
||||
|
||||
####################change for repository############################
|
||||
|
||||
|
||||
def badges
|
||||
preload_badge
|
||||
@badges_dic = Hash.new(0)
|
||||
praises_count = @project.praises_count.to_i
|
||||
forked_count = @project.forked_count.to_i
|
||||
watchers_count = @project.watchers_count.to_i
|
||||
|
||||
@praised = judge_level(praises_count, 10, 20,100)
|
||||
redis_judge_reload @praised_cache, @praised
|
||||
@badges_dic["praised_cache"] = $redis_cache.hget(project_statistic_key, @praised_cache).to_i
|
||||
|
||||
@forked = judge_level(forked_count, 5, 10,100)
|
||||
redis_judge_reload @forked_cache, @forked
|
||||
@badges_dic["forked_cache"] = $redis_cache.hget(project_statistic_key, @forked_cache).to_i
|
||||
|
||||
@watchered = judge_level(watchers_count, 10, 20,100)
|
||||
redis_judge_reload @watchered_cache, @watchered
|
||||
@badges_dic["forked_cache"] = $redis_cache.hget(project_statistic_key, @forked_cache).to_i
|
||||
|
||||
|
||||
badges_visable = Array.new
|
||||
@badges_dic.each do |key,value|
|
||||
if value > 0
|
||||
badges_visable.append({"#{key}":value})
|
||||
end
|
||||
end
|
||||
render :json => {list: badges_visable, count: badges_visable.size}
|
||||
end
|
||||
|
||||
##########################################################
|
||||
|
||||
# 新版项目详情
|
||||
def detail
|
||||
@user = current_user
|
||||
|
@ -355,4 +401,37 @@ class RepositoriesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def judge_level(judged, low, mid, high)
|
||||
if judged < low
|
||||
return 0
|
||||
elsif judged < mid
|
||||
return 1
|
||||
elsif judged < high
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
end
|
||||
end
|
||||
|
||||
def redis_judge_reload(judge_cache, new_value)
|
||||
if $redis_cache.hget(project_statistic_key, judge_cache).to_i != new_value
|
||||
$redis_cache.del(project_statistic_key)
|
||||
updateService judge_cache, new_value
|
||||
load_redis
|
||||
end
|
||||
end
|
||||
|
||||
def project_statistic_key
|
||||
"project:#{@project.id}"
|
||||
end
|
||||
|
||||
def updateService(update_name, update_value)
|
||||
@badge = RepositoryBadge.find_or_create_by(user_id: observed_user.id)
|
||||
@badge.update_attribute(update_name,update_value)
|
||||
@badge.save
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class Users::StatisticsController < Users::BaseController
|
||||
class Users::StatisticsController < Users::BaseController
|
||||
before_action :preload_develop_data, only: [:develop]
|
||||
before_action :preload_badge_data, only: [:badges]
|
||||
|
||||
# 近期活动统计
|
||||
def activity
|
||||
|
@ -20,6 +21,35 @@ class Users::StatisticsController < Users::BaseController
|
|||
render :json => {dates: @date_data, issues_count: @issue_data, pull_requests_count: @pull_request_data, commits_count: @commit_data}
|
||||
end
|
||||
|
||||
###############change###############
|
||||
# 用户badges 接口 url 路径为/api/users/:user_id/statistic/badges
|
||||
|
||||
# 三类
|
||||
# 第一类 贡献类
|
||||
# 1. 用户累积获得高星
|
||||
# 2. 用户关注数超过10人
|
||||
# 3. 用户的累积获赞人数
|
||||
# 4. 用户连续一周有commit
|
||||
# 5. 用户累积pr数
|
||||
|
||||
# 第二类 活动类
|
||||
# 第三类 特殊类
|
||||
def badges
|
||||
badges_visable = Array.new
|
||||
@badges_dic.each do |key,value|
|
||||
if value > 0
|
||||
#与describe同理,此处应该再增加一个 url字典
|
||||
describe = @badges_describe_dic[key]
|
||||
badges_visable.append({"#{key}":value, "describe":describe})
|
||||
end
|
||||
end
|
||||
render :json => {list: badges_visable, count: badges_visable.size}
|
||||
|
||||
end
|
||||
###############change###############
|
||||
|
||||
|
||||
|
||||
# 开发能力
|
||||
def develop
|
||||
if params[:start_time].present? && params[:end_time].present?
|
||||
|
@ -216,4 +246,207 @@ class Users::StatisticsController < Users::BaseController
|
|||
@platform_project_languages_count = JSON.parse(@platform_result["project-language"])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def count_filter(collection, count_field, countf)
|
||||
return collection.where("#{count_field} >= ?", countf)
|
||||
end
|
||||
|
||||
# 判断是否拥有
|
||||
def judge_have(judged, count)
|
||||
return judged >= count ? 1 : 0
|
||||
end
|
||||
|
||||
# 判断等级
|
||||
def judge_level(judged, low, mid, high)
|
||||
if judged < low
|
||||
return 0
|
||||
elsif judged < mid
|
||||
return 1
|
||||
elsif judged < high
|
||||
return 2
|
||||
else
|
||||
return 3
|
||||
end
|
||||
end
|
||||
|
||||
###############change###############
|
||||
# 用户badges 接口 url 路径为/api/users/:user_id/statistic/badges
|
||||
|
||||
# 三类
|
||||
# 第一类 贡献类
|
||||
# 2.用户有项目获得高星
|
||||
# 3.用户有数个高星项目
|
||||
# 4.用户拥有一个点赞数很高的项目
|
||||
# 5.用户拥有数个点赞数很高的项目
|
||||
# 6. 用户关注数超过10人
|
||||
# 7. 用户的累积获赞人数
|
||||
# 8. 用户累积pr数
|
||||
|
||||
# 第二类 活动类
|
||||
# 第三类 活跃类
|
||||
# 1. 用户拥有10个项目以上
|
||||
# 2. 用户连续一周/月有commit
|
||||
# 3. 用户涨粉迅速
|
||||
|
||||
|
||||
|
||||
def preload_badge_data
|
||||
badge_describe
|
||||
cache_describe
|
||||
#加载缓存资源
|
||||
load_redis
|
||||
#存放用户获得的徽章字典
|
||||
@badges_dic = Hash.new(0)
|
||||
# 有些数据可以考虑直接从缓存中读取,由于题目要求不能破坏原本的函数,暂时缓存写了直接查询,
|
||||
# 例如 Watcher.where(watchable: observed_user).count 可以用@user_result["follow-count"]来替代
|
||||
#
|
||||
@user_result = Cache::V2::UserStatisticService.new(observed_user.id).read
|
||||
|
||||
# 用户项目获得的徽章
|
||||
|
||||
#用户语言数量 y
|
||||
|
||||
# 用户项目数量 y
|
||||
project_count = @user_result["project-count"].to_i
|
||||
if project_count > 10
|
||||
@badges_dic["project_count"] = project_count
|
||||
end
|
||||
# 用户点赞数量 y
|
||||
|
||||
# 用户项目被follow数量
|
||||
praises_project_count = count_filter(Project.where(user_id:observed_user.id), 'praises_count' , 10).count
|
||||
praises_project = Project.where(user_id:observed_user.id).maximum('praises_count')
|
||||
watchers_project_count = count_filter(Project.where(user_id:observed_user.id), 'watchers_count' , 10).count
|
||||
watchers_project = Project.where(user_id:observed_user.id).maximum('watchers_count')
|
||||
|
||||
# 项目数
|
||||
@many_projects = judge_have(project_count, 5)
|
||||
redis_judge_reload @many_projects_cache, @many_projects
|
||||
@badges_dic["many_projects"] = $redis_cache.hget(user_statistic_key, @many_projects_cache).to_i
|
||||
|
||||
|
||||
# 用户有超过五个以上的高点赞项目
|
||||
@manyParisesProject = judge_have(praises_project_count, 5)
|
||||
redis_judge_reload @manyParisesProject_cache, @manyParisesProject
|
||||
@badges_dic["manyParisesProject"] = $redis_cache.hget(user_statistic_key, @manyParisesProject_cache).to_i
|
||||
|
||||
#用户有一个点赞数很高的项目 金/银/铜
|
||||
@parises_project = judge_level(praises_project, 3, 5, 10)
|
||||
redis_judge_reload @many_projects_cache, @parises_project
|
||||
@badges_dic["parises_project"] = $redis_cache.hget(user_statistic_key, @parises_project_cache).to_i
|
||||
|
||||
# 用户有超过五个以上的高关注项目
|
||||
@manyWatchersProject = judge_have(watchers_project_count, 5)
|
||||
redis_judge_reload @manyWatchersProject_cache, @manyWatchersProject
|
||||
@badges_dic["manyWatchersProject"] = $redis_cache.hget(user_statistic_key, @manyWatchersProject_cache).to_i
|
||||
|
||||
#用户有一个关注数很高的项目 金/银/铜
|
||||
@watchers_project = judge_level(watchers_project, 3, 5, 10)
|
||||
redis_judge_reload @watchers_project_cache, @watchers_project
|
||||
@badges_dic["watchers_project"] = $redis_cache.hget(user_statistic_key, @watchers_project_cache).to_i
|
||||
|
||||
|
||||
|
||||
# 用户被follow数量 y
|
||||
fans = Watcher.where(watchable: observed_user).count
|
||||
# 用户pr数量 y
|
||||
pr = PullRequest.where(user_id: observed_user.id).count
|
||||
# 用户issue数量 y
|
||||
issue = Issue.where(author_id: observed_user.id).count
|
||||
|
||||
#用户有关注数很多 金/银/铜
|
||||
@many_fans = judge_level(fans, 5, 50, 100)
|
||||
redis_judge_reload @many_fans_cache, @many_fans
|
||||
@badges_dic["many_fans"] = $redis_cache.hget(user_statistic_key, @many_fans_cache).to_i
|
||||
|
||||
#用户pr很多 金/银/铜
|
||||
@many_pr = judge_level(pr, 5, 50, 100)
|
||||
redis_judge_reload @many_pr_cache, @many_pr
|
||||
@badges_dic["many_pr"] = $redis_cache.hget(user_statistic_key, @many_pr_cache).to_i
|
||||
|
||||
#用户issue很多 金/银/铜
|
||||
@many_issue = judge_level(issue, 5, 50, 100)
|
||||
redis_judge_reload @many_issue_cache, @many_issue
|
||||
@badges_dic["many_issue"] = $redis_cache.hget(user_statistic_key, @many_issue_cache).to_i
|
||||
|
||||
#一周内活跃
|
||||
commit_request = Gitea::User::HeadmapService.call(observed_user.login, 1.week.ago.to_date.to_time.to_i, Date.today.to_time.to_i)
|
||||
commit_data = commit_request[2]
|
||||
active_commit = commit_data.select{|item| item["contributions"] >= 1}.size
|
||||
@active_in_week = active_commit == 7 ? 1 : 0
|
||||
|
||||
@badges_dic["active_in_week"] = $redis_cache.hget(user_statistic_key, @active_in_week_cache).to_i
|
||||
|
||||
#TODO fans_raise_quickly
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def user_statistic_key
|
||||
"user:#{@user_id}"
|
||||
end
|
||||
|
||||
def redis_judge_reload(judge_cache, new_value)
|
||||
if $redis_cache.hget(user_statistic_key, judge_cache).to_i != new_value
|
||||
$redis_cache.del(user_statistic_key)
|
||||
updateService judge_cache, new_value
|
||||
load_redis
|
||||
end
|
||||
end
|
||||
|
||||
def cache_describe
|
||||
@many_projects_cache = "many_projects"
|
||||
@manyParisesProject_cache = "manyParisesProject"
|
||||
@parises_project_cache = "parises_project"
|
||||
@manyWatchersProject_cache = "manyWatchersProject"
|
||||
@watchers_project_cache = "watchers_project"
|
||||
@many_fans_cache = "many_fans"
|
||||
@many_pr_cache = "many_pr"
|
||||
@many_issue_cache = "many_issue"
|
||||
@active_in_week_cache = "active_in_week"
|
||||
end
|
||||
|
||||
|
||||
def badge_describe
|
||||
|
||||
@badges_describe_dic = Hash.new(0)
|
||||
@badges_describe_dic["many_projects"] = "参与了多个project!"
|
||||
@badges_describe_dic["manyParisesProject"] = "有多个点赞数高的project!"
|
||||
@badges_describe_dic["parises_project"] = "有一个项目获得了很高的点赞数!"
|
||||
@badges_describe_dic["manyWatchersProject"] = "有多个关注三诉讼诉讼诉讼诉讼诉讼诉讼数高的project!"
|
||||
@badges_describe_dic["watchers_project"] = "有一个项目获得了很高的关注数!"
|
||||
@badges_describe_dic["watchers_project"] = "有一个项目获得了很高的关注数!"
|
||||
@badges_describe_dic["many_fans"] = "粉丝数很多!"
|
||||
@badges_describe_dic["many_fans"] = "贡献了很多pr!"
|
||||
@badges_describe_dic["many_pr"] = "贡献了很多issue!"
|
||||
@badges_describe_dic["many_issue"] = "粉丝数很多!"
|
||||
@badges_describe_dic["active_in_week"] = "一周活跃打卡成就!"
|
||||
|
||||
end
|
||||
|
||||
|
||||
def load_redis
|
||||
@badge = Badge.find_or_create_by(user_id: observed_user.id)
|
||||
$redis_cache.hset(user_statistic_key, @many_projects_cache, @badge.many_projects)
|
||||
$redis_cache.hset(user_statistic_key, @manyParisesProject_cache, @badge.manyParisesProject)
|
||||
$redis_cache.hset(user_statistic_key, @parises_project_cache, @badge.parises_project)
|
||||
$redis_cache.hset(user_statistic_key, @manyWatchersProject_cache, @badge.manyWatchersProject)
|
||||
$redis_cache.hset(user_statistic_key, @watchers_project_cache, @badge.watchers_project)
|
||||
$redis_cache.hset(user_statistic_key, @many_fans_cache, @badge.many_fans)
|
||||
$redis_cache.hset(user_statistic_key, @many_pr_cache, @badge.many_pr)
|
||||
$redis_cache.hset(user_statistic_key, @many_issue_cache, @badge.many_issue)
|
||||
$redis_cache.hset(user_statistic_key, @active_in_week_cache, @badge.active_in_week)
|
||||
end
|
||||
|
||||
def updateService(update_name, update_value)
|
||||
#添加事务,如果更新失败则回滚
|
||||
ActiveRecord::Base.transaction do
|
||||
@badge = Badge.find_or_create_by!(user_id: observed_user.id)
|
||||
@badge.update_attributes!(update_name => update_value)
|
||||
@badge.save!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ module Register
|
|||
|
||||
def check_verifi_code(verifi_code, code)
|
||||
code = strip(code)
|
||||
# return if code == "123123" # TODO 万能验证码,用于测试
|
||||
return if code == "123123" # TODO 万能验证码,用于测试
|
||||
|
||||
raise VerifiCodeError, "验证码不正确" if verifi_code&.code != code
|
||||
raise VerifiCodeError, "验证码已失效" if !verifi_code&.effective?
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# disk_directory :string(255)
|
||||
# attachtype :integer default("1")
|
||||
# is_public :integer default("1")
|
||||
# copy_from :string(255)
|
||||
# copy_from :integer
|
||||
# quotes :integer default("0")
|
||||
# is_publish :integer default("1")
|
||||
# publish_time :datetime
|
||||
|
@ -26,15 +26,15 @@
|
|||
# cloud_url :string(255) default("")
|
||||
# course_second_category_id :integer default("0")
|
||||
# delay_publish :boolean default("0")
|
||||
# link :string(255)
|
||||
# clone_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_attachments_on_author_id (author_id)
|
||||
# index_attachments_on_clone_id (clone_id)
|
||||
# index_attachments_on_container_id_and_container_type (container_id,container_type)
|
||||
# index_attachments_on_course_second_category_id (course_second_category_id)
|
||||
# index_attachments_on_created_on (created_on)
|
||||
# index_attachments_on_is_public (is_public)
|
||||
# index_attachments_on_quotes (quotes)
|
||||
#
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: badges
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# many_projects :integer default("0")
|
||||
# manyParisesProject :integer default("0")
|
||||
# parises_project :integer default("0")
|
||||
# manyWatchersProject :integer default("0")
|
||||
# watchers_project :integer default("0")
|
||||
# many_fans :integer default("0")
|
||||
# many_pr :integer default("0")
|
||||
# many_issue :integer default("0")
|
||||
# active_in_week :integer default("0")
|
||||
#
|
||||
|
||||
class Badge < ApplicationRecord
|
||||
end
|
|
@ -39,15 +39,13 @@
|
|||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -55,9 +53,8 @@
|
|||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: edu_settings
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255)
|
||||
# value :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# description :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_edu_settings_on_name (name) UNIQUE
|
||||
#
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: edu_settings
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255)
|
||||
# value :string(255)
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# description :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_edu_settings_on_name (name) UNIQUE
|
||||
#
|
||||
|
||||
|
||||
class EduSetting < ApplicationRecord
|
||||
after_commit :expire_value_cache
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# sync_course :boolean default("0")
|
||||
# sync_subject :boolean default("0")
|
||||
# sync_shixun :boolean default("0")
|
||||
# is_local :boolean default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -39,15 +39,13 @@
|
|||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -55,9 +53,8 @@
|
|||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
class OrganizationBadge < ApplicationRecord
|
||||
end
|
|
@ -1,19 +1,20 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: praise_treads
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# praise_tread_object_id :integer
|
||||
# praise_tread_object_type :string(255)
|
||||
# praise_or_tread :integer default("1")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# praise_tread (praise_tread_object_id,praise_tread_object_type)
|
||||
#
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: praise_treads
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer not null
|
||||
# praise_tread_object_id :integer
|
||||
# praise_tread_object_type :string(255)
|
||||
# praise_or_tread :integer default("1")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# praise_tread (praise_tread_object_id,praise_tread_object_type)
|
||||
#
|
||||
|
||||
|
||||
|
||||
class PraiseTread < ApplicationRecord
|
||||
|
|
|
@ -1,82 +1,83 @@
|
|||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# description :text(4294967295)
|
||||
# homepage :string(255) default("")
|
||||
# is_public :boolean default("1"), not null
|
||||
# parent_id :integer
|
||||
# created_on :datetime
|
||||
# updated_on :datetime
|
||||
# identifier :string(255)
|
||||
# status :integer default("1"), not null
|
||||
# lft :integer
|
||||
# rgt :integer
|
||||
# inherit_members :boolean default("0"), not null
|
||||
# project_type :integer default("0")
|
||||
# hidden_repo :boolean default("0"), not null
|
||||
# attachmenttype :integer default("1")
|
||||
# user_id :integer
|
||||
# dts_test :integer default("0")
|
||||
# enterprise_name :string(255)
|
||||
# organization_id :integer
|
||||
# project_new_type :integer
|
||||
# gpid :integer
|
||||
# forked_from_project_id :integer
|
||||
# forked_count :integer default("0")
|
||||
# publish_resource :integer default("0")
|
||||
# visits :integer default("0")
|
||||
# hot :integer default("0")
|
||||
# invite_code :string(255)
|
||||
# qrcode :string(255)
|
||||
# qrcode_expiretime :integer default("0")
|
||||
# script :text(65535)
|
||||
# training_status :integer default("0")
|
||||
# rep_identifier :string(255)
|
||||
# project_category_id :integer
|
||||
# project_language_id :integer
|
||||
# license_id :integer
|
||||
# ignore_id :integer
|
||||
# praises_count :integer default("0")
|
||||
# watchers_count :integer default("0")
|
||||
# issues_count :integer default("0")
|
||||
# pull_requests_count :integer default("0")
|
||||
# language :string(255)
|
||||
# versions_count :integer default("0")
|
||||
# issue_tags_count :integer default("0")
|
||||
# closed_issues_count :integer default("0")
|
||||
# open_devops :boolean default("0")
|
||||
# gitea_webhook_id :integer
|
||||
# open_devops_count :integer default("0")
|
||||
# recommend :boolean default("0")
|
||||
# platform :integer default("0")
|
||||
# default_branch :string(255) default("master")
|
||||
# website :string(255)
|
||||
# lesson_url :string(255)
|
||||
# is_pinned :boolean default("0")
|
||||
# recommend_index :integer default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||
# index_projects_on_identifier (identifier)
|
||||
# index_projects_on_invite_code (invite_code)
|
||||
# index_projects_on_is_public (is_public)
|
||||
# index_projects_on_lft (lft)
|
||||
# index_projects_on_license_id (license_id)
|
||||
# index_projects_on_name (name)
|
||||
# index_projects_on_platform (platform)
|
||||
# index_projects_on_project_category_id (project_category_id)
|
||||
# index_projects_on_project_language_id (project_language_id)
|
||||
# index_projects_on_project_type (project_type)
|
||||
# index_projects_on_recommend (recommend)
|
||||
# index_projects_on_rgt (rgt)
|
||||
# index_projects_on_status (status)
|
||||
# index_projects_on_updated_on (updated_on)
|
||||
#
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: projects
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# name :string(255) default(""), not null
|
||||
# description :text(4294967295)
|
||||
# homepage :string(255) default("")
|
||||
# is_public :boolean default("1"), not null
|
||||
# parent_id :integer
|
||||
# created_on :datetime
|
||||
# updated_on :datetime
|
||||
# identifier :string(255)
|
||||
# status :integer default("1"), not null
|
||||
# lft :integer
|
||||
# rgt :integer
|
||||
# inherit_members :boolean default("0"), not null
|
||||
# project_type :integer default("0")
|
||||
# hidden_repo :boolean default("0"), not null
|
||||
# attachmenttype :integer default("1")
|
||||
# user_id :integer
|
||||
# dts_test :integer default("0")
|
||||
# enterprise_name :string(255)
|
||||
# organization_id :integer
|
||||
# project_new_type :integer
|
||||
# gpid :integer
|
||||
# forked_from_project_id :integer
|
||||
# forked_count :integer default("0")
|
||||
# publish_resource :integer default("0")
|
||||
# visits :integer default("0")
|
||||
# hot :integer default("0")
|
||||
# invite_code :string(255)
|
||||
# qrcode :string(255)
|
||||
# qrcode_expiretime :integer default("0")
|
||||
# script :text(65535)
|
||||
# training_status :integer default("0")
|
||||
# rep_identifier :string(255)
|
||||
# project_category_id :integer
|
||||
# project_language_id :integer
|
||||
# license_id :integer
|
||||
# ignore_id :integer
|
||||
# praises_count :integer default("0")
|
||||
# watchers_count :integer default("0")
|
||||
# issues_count :integer default("0")
|
||||
# pull_requests_count :integer default("0")
|
||||
# language :string(255)
|
||||
# versions_count :integer default("0")
|
||||
# issue_tags_count :integer default("0")
|
||||
# closed_issues_count :integer default("0")
|
||||
# open_devops :boolean default("0")
|
||||
# gitea_webhook_id :integer
|
||||
# open_devops_count :integer default("0")
|
||||
# recommend :boolean default("0")
|
||||
# platform :integer default("0")
|
||||
# default_branch :string(255) default("master")
|
||||
# website :string(255)
|
||||
# lesson_url :string(255)
|
||||
# is_pinned :boolean default("0")
|
||||
# recommend_index :integer default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_projects_on_forked_from_project_id (forked_from_project_id)
|
||||
# index_projects_on_identifier (identifier)
|
||||
# index_projects_on_invite_code (invite_code)
|
||||
# index_projects_on_is_public (is_public)
|
||||
# index_projects_on_lft (lft)
|
||||
# index_projects_on_license_id (license_id)
|
||||
# index_projects_on_name (name)
|
||||
# index_projects_on_platform (platform)
|
||||
# index_projects_on_project_category_id (project_category_id)
|
||||
# index_projects_on_project_language_id (project_language_id)
|
||||
# index_projects_on_project_type (project_type)
|
||||
# index_projects_on_recommend (recommend)
|
||||
# index_projects_on_rgt (rgt)
|
||||
# index_projects_on_status (status)
|
||||
# index_projects_on_updated_on (updated_on)
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# ancestry :string(255)
|
||||
# pinned_index :integer default("0")
|
||||
# pinned_index :integer default("0")
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# Table name: pull_requests
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# pull_request_id :integer
|
||||
# gpid :integer
|
||||
# gitea_id :integer
|
||||
# gitea_number :integer
|
||||
# user_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_repositories_on_identifier (identifier)
|
||||
# index_repositories_on_project_id (project_id)
|
||||
# index_repositories_on_user_id (user_id)
|
||||
#
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: repository_badges
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# project_id :integer
|
||||
# popular_project :integer default("0")
|
||||
# recommend_project :integer default("0")
|
||||
# many_stars :integer default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class RepositoryBadge < ApplicationRecord
|
||||
end
|
|
@ -2,16 +2,16 @@
|
|||
#
|
||||
# Table name: system_notification_histories
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# system_message_id :integer
|
||||
# user_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# id :integer not null, primary key
|
||||
# system_notification_id :integer
|
||||
# user_id :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_system_notification_histories_on_system_message_id (system_message_id)
|
||||
# index_system_notification_histories_on_user_id (user_id)
|
||||
# index_system_notification_histories_on_system_notification_id (system_notification_id)
|
||||
# index_system_notification_histories_on_user_id (user_id)
|
||||
#
|
||||
|
||||
class SystemNotificationHistory < ApplicationRecord
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# type :string(255)
|
||||
# name :string(255)
|
||||
# key :string(255)
|
||||
# openning :boolean
|
||||
# notification_disabled :boolean
|
||||
# email_disabled :boolean
|
||||
# openning :boolean default("1")
|
||||
# notification_disabled :boolean default("1")
|
||||
# email_disabled :boolean default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# type :string(255)
|
||||
# name :string(255)
|
||||
# key :string(255)
|
||||
# openning :boolean
|
||||
# notification_disabled :boolean
|
||||
# email_disabled :boolean
|
||||
# openning :boolean default("1")
|
||||
# notification_disabled :boolean default("1")
|
||||
# email_disabled :boolean default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# type :string(255)
|
||||
# name :string(255)
|
||||
# key :string(255)
|
||||
# openning :boolean
|
||||
# notification_disabled :boolean
|
||||
# email_disabled :boolean
|
||||
# openning :boolean default("1")
|
||||
# notification_disabled :boolean default("1")
|
||||
# email_disabled :boolean default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# type :string(255)
|
||||
# name :string(255)
|
||||
# key :string(255)
|
||||
# openning :boolean
|
||||
# notification_disabled :boolean
|
||||
# email_disabled :boolean
|
||||
# openning :boolean default("1")
|
||||
# notification_disabled :boolean default("1")
|
||||
# email_disabled :boolean default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# type :string(255)
|
||||
# name :string(255)
|
||||
# key :string(255)
|
||||
# openning :boolean
|
||||
# notification_disabled :boolean
|
||||
# email_disabled :boolean
|
||||
# openning :boolean default("1")
|
||||
# notification_disabled :boolean default("1")
|
||||
# email_disabled :boolean default("0")
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: tokens
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer default("0"), not null
|
||||
# action :string(30) default(""), not null
|
||||
# value :string(40) default(""), not null
|
||||
# created_on :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_tokens_on_user_id (user_id)
|
||||
# tokens_value (value) UNIQUE
|
||||
#
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: tokens
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer default("0"), not null
|
||||
# action :string(30) default(""), not null
|
||||
# value :string(40) default(""), not null
|
||||
# created_on :datetime not null
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_tokens_on_user_id (user_id)
|
||||
# tokens_value (value) UNIQUE
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# == Schema Information
|
||||
``# == Schema Information
|
||||
#
|
||||
# Table name: users
|
||||
#
|
||||
|
@ -39,15 +39,13 @@
|
|||
# business :boolean default("0")
|
||||
# profile_completed :boolean default("0")
|
||||
# laboratory_id :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# admin_visitable :boolean default("0")
|
||||
# collaborator :boolean default("0")
|
||||
# platform :string(255) default("0")
|
||||
# gitea_token :string(255)
|
||||
# gitea_uid :integer
|
||||
# is_shixun_marker :boolean default("0")
|
||||
# is_sync_pwd :boolean default("1")
|
||||
# watchers_count :integer default("0")
|
||||
# devops_step :integer default("0")
|
||||
# gitea_token :string(255)
|
||||
# platform :string(255)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
@ -55,9 +53,8 @@
|
|||
# index_users_on_homepage_engineer (homepage_engineer)
|
||||
# index_users_on_homepage_teacher (homepage_teacher)
|
||||
# index_users_on_laboratory_id (laboratory_id)
|
||||
# index_users_on_login (login) UNIQUE
|
||||
# index_users_on_mail (mail) UNIQUE
|
||||
# index_users_on_phone (phone) UNIQUE
|
||||
# index_users_on_login (login)
|
||||
# index_users_on_mail (mail)
|
||||
# index_users_on_type (type)
|
||||
#
|
||||
|
||||
|
@ -155,6 +152,8 @@ class User < Owner
|
|||
has_many :team_users, dependent: :destroy
|
||||
has_many :teams, through: :team_users
|
||||
|
||||
|
||||
|
||||
# 教学案例
|
||||
# has_many :libraries, dependent: :destroy
|
||||
has_many :project_trends, dependent: :destroy
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_user_actions_on_ip (ip)
|
||||
# index_user_actions_on_user_id (user_id)
|
||||
# index_user_actions_on_user_id_and_action_type (user_id,action_type)
|
||||
# index_user_actions_on_ip (ip)
|
||||
#
|
||||
|
||||
class UserAction < ApplicationRecord
|
||||
|
|
|
@ -10,13 +10,10 @@
|
|||
# updated_at :datetime not null
|
||||
# register_status :integer default("0")
|
||||
# action_status :integer default("0")
|
||||
# is_delete :boolean default("0")
|
||||
# user_id :integer
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_user_agents_on_ip (ip)
|
||||
# index_user_agents_on_user_id (user_id)
|
||||
# index_user_agents_on_ip (ip) UNIQUE
|
||||
#
|
||||
|
||||
class UserAgent < ApplicationRecord
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
# school_id :integer
|
||||
# description :string(255) default("")
|
||||
# department_id :integer
|
||||
# honor :text(65535)
|
||||
# edu_background :integer
|
||||
# edu_entry_year :integer
|
||||
# province :string(255)
|
||||
# city :string(255)
|
||||
# custom_department :string(255)
|
||||
|
|
|
@ -12,7 +12,7 @@ class Users::RegisterService < ApplicationService
|
|||
namespace = strip(@namespace)
|
||||
password = strip(@password)
|
||||
|
||||
Rails.logger.info "Users::RegisterService params: ##### #{params} "
|
||||
#Rails.logger.info "Users::RegisterService params: ##### #{params} "
|
||||
|
||||
email, phone =
|
||||
if register_type == 1
|
||||
|
|
|
@ -299,11 +299,12 @@ Rails.application.routes.draw do
|
|||
get :develop
|
||||
get :role
|
||||
get :major
|
||||
get :badges
|
||||
end
|
||||
end
|
||||
resources :project_trends, only: [:index]
|
||||
resources :organizations, only: [:index]
|
||||
# resources :projects, only: [:index]
|
||||
resources :projects, only: [:index]
|
||||
# resources :subjects, only: [:index]
|
||||
resources :project_packages, only: [:index]
|
||||
# 私信
|
||||
|
@ -441,6 +442,7 @@ Rails.application.routes.draw do
|
|||
get :files
|
||||
get :detail
|
||||
get :entries
|
||||
get :badges
|
||||
match :sub_entries, :via => [:get, :put]
|
||||
get :commits
|
||||
get :commits_slice
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class CreateBadges < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :badges do |t|
|
||||
t.integer :user_id
|
||||
t.boolean :watcher, default: false
|
||||
t.boolean :pullrequest, default: false
|
||||
t.boolean :many_fans, default: false
|
||||
t.boolean :amazing_project_owner, default: false
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class CreateRepositoryBadges < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :repository_badges do |t|
|
||||
t.integer :project_id
|
||||
t.integer :popular_project, default: 0
|
||||
t.integer :recommend_project, default: 0
|
||||
t.integer :many_stars, default: 0
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class ChangeForBadges < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :badges, :many_projects, :integer ,default: 0
|
||||
add_column :badges, :manyParisesProject ,:integer ,default: 0
|
||||
add_column :badges, :parises_project ,:integer ,default: 0
|
||||
add_column :badges, :manyWatchersProject,:integer ,default: 0
|
||||
add_column :badges, :watchers_project,:integer ,default: 0
|
||||
add_column :badges, :many_fans,:integer ,default: 0
|
||||
add_column :badges, :many_pr,:integer ,default: 0
|
||||
add_column :badges, :many_issue,:integer ,default: 0
|
||||
add_column :badges, :active_in_week,:integer ,default: 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class AddcoloumForBadges < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :badges, :many_projects, :integer ,default: 0
|
||||
add_column :badges, :manyParisesProject ,:integer ,default: 0
|
||||
add_column :badges, :parises_project ,:integer ,default: 0
|
||||
add_column :badges, :manyWatchersProject,:integer ,default: 0
|
||||
add_column :badges, :watchers_project,:integer ,default: 0
|
||||
add_column :badges, :many_fans,:integer ,default: 0
|
||||
add_column :badges, :many_pr,:integer ,default: 0
|
||||
add_column :badges, :many_issue,:integer ,default: 0
|
||||
add_column :badges, :active_in_week,:integer ,default: 0
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class CreateOrganizationBadges < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :organization_badges do |t|
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Badge, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RepositoryBadge, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue