Merge branch 'standalone_develop' into pre_trustie_server

This commit is contained in:
xxq250 2023-04-17 11:08:51 +08:00
commit 5a2659253e
12 changed files with 327 additions and 248 deletions

View File

@ -19,9 +19,10 @@ class CommitLogsController < ApplicationController
params[:commits].each do |commit| params[:commits].each do |commit|
commit_id = commit[:id] commit_id = commit[:id]
message = commit[:message] message = commit[:message]
CommitLog.create(user: user, project: project, repository_id: repository_id, commit_log = CommitLog.create(user: user, project: project, repository_id: repository_id,
name: repository_name, full_name: repository_full_name, name: repository_name, full_name: repository_full_name,
ref: ref, commit_id: commit_id, message: message) ref: ref, commit_id: commit_id, message: message)
commit_log.project_trends.create(user_id: user.id, project_id: project&.id, action_type: "create")
# 统计数据新增 # 统计数据新增
CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id) CacheAsyncSetJob.perform_later("project_common_service", {commits: 1}, project.id)
end end

View File

@ -1,10 +1,13 @@
class ProjectRankController < ApplicationController class ProjectRankController < ApplicationController
# 根据时间获取热门项目 # 根据时间获取热门项目
def index def index
limit = 9
limit = params[:limit].to_i - 1 if params[:limit].present?
limit = 99 if limit > 99
$redis_cache.zunionstore("recent-days-project-rank-#{time}", get_timeable_key_names) $redis_cache.zunionstore("recent-days-project-rank-#{time}", get_timeable_key_names)
deleted_data = $redis_cache.smembers("v2-project-rank-deleted") deleted_data = $redis_cache.smembers("v2-project-rank-deleted")
$redis_cache.zrem("recent-days-project-rank-#{time}", deleted_data) unless deleted_data.blank? $redis_cache.zrem("recent-days-project-rank-#{time}", deleted_data) unless deleted_data.blank?
@project_rank = $redis_cache.zrevrange("recent-days-project-rank-#{time}", 0, 9, withscores: true) @project_rank = $redis_cache.zrevrange("recent-days-project-rank-#{time}", 0, limit, withscores: true)
rescue Exception => e rescue Exception => e
@project_rank = [] @project_rank = []
end end

View File

@ -1,6 +1,6 @@
class ProjectTrendsController < ApplicationController class ProjectTrendsController < ApplicationController
before_action :load_repository before_action :load_repository, except: [:last]
before_action :check_project_public before_action :check_project_public, except: [:last]
def index def index
project_trends = @project.project_trends.preload(:user, trend: :user, project: :owner) project_trends = @project.project_trends.preload(:user, trend: :user, project: :owner)
@ -42,6 +42,14 @@ class ProjectTrendsController < ApplicationController
@project_trends = project_trends.page(@page).per(@limit) @project_trends = project_trends.page(@page).per(@limit)
end end
def last
project_trends = ProjectTrend.preload(:user, trend: :user, project: :owner).order("id desc")
@page = params[:page] || 1
@limit = params[:limit] || 20
@project_trends_count = project_trends.count
@project_trends = project_trends.page(@page).per(@limit)
end
private private
def check_project_public def check_project_public

View File

@ -1,8 +1,11 @@
class UserRankController < ApplicationController class UserRankController < ApplicationController
# 根据时间获取热门开发者 # 根据时间获取热门开发者
def index def index
limit = 3
limit = params[:limit].to_i - 1 if params[:limit].present?
limit = 99 if limit > 99
$redis_cache.zunionstore("recent-days-user-rank", get_timeable_key_names) $redis_cache.zunionstore("recent-days-user-rank", get_timeable_key_names)
@user_rank = $redis_cache.zrevrange("recent-days-user-rank", 0, 3, withscores: true) @user_rank = $redis_cache.zrevrange("recent-days-user-rank", 0, limit, withscores: true)
rescue Exception => e rescue Exception => e
@user_rank = [] @user_rank = []
end end

View File

@ -3,4 +3,10 @@ class CommitLog < ApplicationRecord
belongs_to :project belongs_to :project
belongs_to :repository belongs_to :repository
has_many :project_trends, as: :trend, dependent: :destroy
def title
self.message
end
end end

View File

@ -28,4 +28,6 @@ json.forks project_common["forks"]
json.watchers project_common["watchers"] json.watchers project_common["watchers"]
json.praises project_common["praises"] json.praises project_common["praises"]
json.issues project_common["issues"] json.issues project_common["issues"]
json.pulls project_common["pullrequests"] json.pulls project_common["pullrequests"]
json.commits project_common["commits"]
json.issues project_common["issues"]

View File

@ -18,6 +18,15 @@ if trend.trend_type == "Issue"
json.partial! "issues/simple_issue_item", locals: {issue: trend.trend} json.partial! "issues/simple_issue_item", locals: {issue: trend.trend}
elsif trend.trend_type == "VersionRelease" elsif trend.trend_type == "VersionRelease"
json.partial! "version_releases/simple_version_release", locals: {version: trend.trend} json.partial! "version_releases/simple_version_release", locals: {version: trend.trend}
elsif trend.trend_type == "CommitLog"
json.commit_log do
commit_log = trend.trend
json.user do
json.partial! 'users/user_simple', locals: {user: commit_log.user}
end
json.ref commit_log.ref.to_s.gsub("refs/heads/", "")
json.extract! commit_log, :id,:name,:full_name,:message, :commit_id,:created_at,:updated_at
end
else else
json.name trend.trend&.title json.name trend.trend&.title
json.created_at format_time(trend.trend&.created_at) json.created_at format_time(trend.trend&.created_at)

View File

@ -0,0 +1,8 @@
json.partial! "commons/success"
json.total_count @project_trends_count
json.project_trends do
json.array! @project_trends.to_a.each do |trend|
json.partial! "detail", trend: trend
end
end

View File

@ -18,4 +18,34 @@ else
json.identifier popular_project_common["identifier"] json.identifier popular_project_common["identifier"]
json.description popular_project_common["description"] json.description popular_project_common["description"]
end end
end end
ids = $redis_cache.zrevrange("v2-user-project-rank:#{item[0]}", 0, 999, withscores: true).map{|a|a[0]}
visits = 0
forks = 0
watchers = 0
praises = 0
issues = 0
pulls = 0
commits = 0
issues = 0
ids.each do |pid|
project_common = $redis_cache.hgetall("v2-project-common:#{pid}")
visits = visits + project_common["visits"].to_i
forks = forks + project_common["forks"].to_i
watchers = watchers + project_common["watchers"].to_i
praises = praises + project_common["praises"].to_i
issues = issues + project_common["issues"].to_i
pulls = pulls + project_common["pullrequests"].to_i
commits = commits + project_common["commits"].to_i
issues = issues + project_common["issues"].to_i
end
json.visits visits
json.forks forks
json.watchers watchers
json.praises praises
json.issues issues
json.pulls pulls
json.commits commits
json.issues issues

View File

@ -1,240 +1,241 @@
zh-CN: zh-CN:
error: error:
record_not_found: 您访问的页面不存在或已被删除 record_not_found: 您访问的页面不存在或已被删除
forbidden: 您没有权限进行该操作 forbidden: 您没有权限进行该操作
unauthorized: 未登录 unauthorized: 未登录
button_test: 测试 button_test: 测试
button_edit: 编辑 button_edit: 编辑
button_delete: 删除 button_delete: 删除
admins_apply_status: admins_apply_status:
status: status:
'pending': '待审批' 'pending': '待审批'
'processed': '已审批' 'processed': '已审批'
'refused': '已拒绝' 'refused': '已拒绝'
'agreed': '已同意' 'agreed': '已同意'
trend: trend:
Issue: 疑修(Issue) Issue: 疑修(Issue)
PullRequest: 合并请求(PR) PullRequest: 合并请求(PR)
VersionRelease: 版本发布 VersionRelease: 版本发布
create: 创建了 CommitLog: 代码(Commit)
journal: 回复了 create: 创建了
close: 关闭了 journal: 回复了
merge: 合并了 close: 关闭了
push: 发布了 merge: 合并了
push: 发布了
version:
draft: 草稿 version:
draft: 草稿
journal_detail:
branch_name: 分支 journal_detail:
close_pr: 合并 branch_name: 分支
merge: 合并 close_pr: 合并
issue_tags_value: 标记 merge: 合并
lock_issue: 锁定工单 issue_tags_value: 标记
unlock_issue: 解锁工单 lock_issue: 锁定工单
destroy_issue_depend: 删除依赖 unlock_issue: 解锁工单
issue_depend: 增加依赖 destroy_issue_depend: 删除依赖
work_time: 开始工作 issue_depend: 增加依赖
cancel_time: 取消时间跟踪 work_time: 开始工作
end_time: 停止工作 cancel_time: 取消时间跟踪
subject: 主题 end_time: 停止工作
description: 描述 subject: 主题
is_private: 私有 description: 描述
assigned_to_id: 指派给 is_private: 私有
tracker_id: 类型 assigned_to_id: 指派给
status_id: 状态 tracker_id: 类型
priority_id: 优先级 status_id: 状态
fixed_version_id: 里程碑 priority_id: 优先级
start_date: 开始日期 fixed_version_id: 里程碑
due_date: 结束日期 start_date: 开始日期
estimated_hours: 添加耗时 due_date: 结束日期
done_ratio: 完成度 estimated_hours: 添加耗时
t: done_ratio: 完成度
f: t:
true: f:
false: true:
issue_tag_ids: 标记 false:
issue_type: 分类 issue_tag_ids: 标记
token: 悬赏金额 issue_type: 分类
close_issue: 工单 token: 悬赏金额
activerecord: close_issue: 工单
attributes: activerecord:
organization: attributes:
login: '组织名称' organization:
user: login: '组织名称'
login: '登录名' user:
lastname: '姓名' login: '登录名'
nickname: '昵称' lastname: '姓名'
discuss: nickname: '昵称'
content: '内容' discuss:
journals_for_message: content: '内容'
notes: '内容' journals_for_message:
subject: notes: '内容'
name: '课程名称' subject:
description: '课程简介' name: '课程名称'
learning_notes: '学习须知' description: '课程简介'
stage: learning_notes: '学习须知'
name: '章节名称' stage:
description: '章节描述' name: '章节名称'
shixun_info: description: '章节描述'
description: '简介' shixun_info:
fork_reason: 'fork原因' description: '简介'
challenge: fork_reason: 'fork原因'
task_pass: '过关任务' challenge:
test_set: task_pass: '过关任务'
input: '输入' test_set:
output: '输出' input: '输入'
challenge_question: output: '输出'
option_name: '选项' challenge_question:
challenge_choose: option_name: '选项'
subject: '题干' challenge_choose:
challenge_answer: subject: '题干'
contents: '答案内容' challenge_answer:
memo: contents: '答案内容'
content: '帖子内容' memo:
course: content: '帖子内容'
name: '课堂名称' course:
course_group: name: '课堂名称'
name: '分班名称' course_group:
course_module: name: '分班名称'
module_name: '目录名称' course_module:
course_second_category: module_name: '目录名称'
name: '目录名称' course_second_category:
inform: name: '目录名称'
name: '标题' inform:
description: '内容' name: '标题'
course_stage: description: '内容'
name: '章节名称' course_stage:
description: '章节描述' name: '章节名称'
attachment: description: '章节描述'
description: '资源描述' attachment:
message: description: '资源描述'
subject: '标题' message:
message_detail: subject: '标题'
content: '内容' message_detail:
homework_common: content: '内容'
name: '标题' homework_common:
description: '内容' name: '标题'
explanation: '内容' description: '内容'
reference_answer: '参考答案' explanation: '内容'
student_work: reference_answer: '参考答案'
description: '内容' student_work:
student_works_score: description: '内容'
comment: '评语' student_works_score:
challenge_work_score: comment: '评语'
comment: '评语' challenge_work_score:
shixun_work_comment: comment: '评语'
comment: '评语' shixun_work_comment:
hidden_comment: '隐藏评语' comment: '评语'
graduation_topic: hidden_comment: '隐藏评语'
name: '选题名称' graduation_topic:
description: '选题简介' name: '选题名称'
graduation_task: description: '选题简介'
name: '任务标题' graduation_task:
description: '内容' name: '任务标题'
graduation_work: description: '内容'
description: '作品内容' graduation_work:
graduation_work_score: description: '作品内容'
comment: '评语' graduation_work_score:
poll: comment: '评语'
polls_name: '问卷标题' poll:
polls_description: '问卷须知' polls_name: '问卷标题'
poll_question: polls_description: '问卷须知'
question_title: '题干' poll_question:
poll_answer: question_title: '题干'
answer_text: '选项' poll_answer:
poll_vote: answer_text: '选项'
vote_text: '内容' poll_vote:
exercise: vote_text: '内容'
exercise_name: '试卷标题' exercise:
exercise_description: '试卷须知' exercise_name: '试卷标题'
exercise_question: exercise_description: '试卷须知'
question_title: '题干' exercise_question:
exercise_choice: question_title: '题干'
choice_text: '选项' exercise_choice:
exercise_answer: choice_text: '选项'
answer_text: '答案' exercise_answer:
exercise_standard_answer: answer_text: '答案'
answer_text: '参考答案' exercise_standard_answer:
exercise_answer_comment: answer_text: '参考答案'
comment: '评语' exercise_answer_comment:
homework_bank: comment: '评语'
name: '标题' homework_bank:
description: '内容' name: '标题'
reference_answer: '参考答案' description: '内容'
gtask_bank: reference_answer: '参考答案'
name: '任务标题' gtask_bank:
description: '内容' name: '任务标题'
gtopic_bank: description: '内容'
name: '选题名称' gtopic_bank:
description: '选题简介' name: '选题名称'
exercise_bank: description: '选题简介'
name: '试卷标题' exercise_bank:
description: '试卷须知' name: '试卷标题'
exercise_bank_question: description: '试卷须知'
question_title: '题干' exercise_bank_question:
exerise_bank_choice: question_title: '题干'
choice_text: '选项' exerise_bank_choice:
exercise_bank_standard_answer: choice_text: '选项'
answer_text: '参考答案' exercise_bank_standard_answer:
library: answer_text: '参考答案'
title: '标题' library:
content: '内容' title: '标题'
author_name: '作者姓名' content: '内容'
author_school_name: '作者单位名称' author_name: '作者姓名'
competition: author_school_name: '作者单位名称'
introduction: '简介' competition:
competition_module_md_content: introduction: '简介'
content: '内容' competition_module_md_content:
chart_rule: content: '内容'
content: '内容' chart_rule:
project_package: content: '内容'
title: '标题' project_package:
examination_bank: title: '标题'
name: '试卷名称' examination_bank:
item_bank: name: '试卷名称'
name: '题干' item_bank:
item_analysis: name: '题干'
analysis: '解析' item_analysis:
item_choice: analysis: '解析'
choice_text: '选项' item_choice:
hack: choice_text: '选项'
name: '任务名称' hack:
description: '描述' name: '任务名称'
hack_set: description: '描述'
input: '测试集输入' hack_set:
output: '测试集输出' input: '测试集输入'
hack_user_lastest_code: output: '测试集输出'
notes: '笔记' hack_user_lastest_code:
trustie_hack: notes: '笔记'
description: '描述' trustie_hack:
discipline: description: '描述'
name: '名称' discipline:
sub_discipline: name: '名称'
name: '名称' sub_discipline:
tag_discipline: name: '名称'
name: '名称' tag_discipline:
live_link: name: '名称'
description: '说明' live_link:
url: '链接' description: '说明'
course_name: '课程名称' url: '链接'
platform: '直播平台' course_name: '课程名称'
live_time: '开播时间' platform: '直播平台'
duration: '直播时长' live_time: '开播时间'
project_language: duration: '直播时长'
name: '项目语言' project_language:
license: name: '项目语言'
name: '许可证名称' license:
content: '许可证内容' name: '许可证名称'
ignore: content: '许可证内容'
name: 'git忽略文件名称' ignore:
content: 'git忽略文件内容' name: 'git忽略文件名称'
feedback_message_history: content: 'git忽略文件内容'
title: '' feedback_message_history:
close_pr: 合并请求 title: ''
roles: close_pr: 合并请求
Developer: 开发者 roles:
Reporter: 报告者 Developer: 开发者
Reporter: 报告者
Manager: 管理员 Manager: 管理员

View File

@ -117,6 +117,7 @@ Rails.application.routes.draw do
get 'home/index' get 'home/index'
get 'home/search' get 'home/search'
get 'main/first_stamp' get 'main/first_stamp'
get 'activity/last', to: 'project_trends#last'
get 'search', to: 'searchs#index' get 'search', to: 'searchs#index'
put 'commons/hidden', to: 'commons#hidden' put 'commons/hidden', to: 'commons#hidden'
@ -763,6 +764,7 @@ Rails.application.routes.draw do
end end
end end
end end
# Project Area END # Project Area END
scope module: :helps do scope module: :helps do

View File

@ -0,0 +1,6 @@
class UpdateCommitLogUtf8 < ActiveRecord::Migration[5.2]
def change
execute("ALTER TABLE `commit_logs` MODIFY `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
execute("ALTER TABLE `commit_logs` MODIFY `full_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;")
end
end