mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
新增:固定数据清洗及获取
This commit is contained in:
@@ -438,4 +438,32 @@ class Project < ApplicationRecord
|
||||
def del_project_issue_cache_delete_count
|
||||
$redis_cache.hdel("issue_cache_delete_count", self.id)
|
||||
end
|
||||
|
||||
def self.mindspore_contributors
|
||||
cache_result = $redis_cache.get("ProjectMindsporeContributors")
|
||||
if cache_result.nil?
|
||||
contributors = []
|
||||
file = File.open('public/mindspore_authors', 'r')
|
||||
file.each_line do |l|
|
||||
itemArray = l.gsub("\r\n", "").split("|:|")
|
||||
email = itemArray[0]
|
||||
username = itemArray[1]
|
||||
commits = itemArray[2].to_i
|
||||
if username =~ CustomRegexp::LOGIN && email =~ CustomRegexp::EMAIL
|
||||
user = User.find_by(login: username, mail: email)
|
||||
else
|
||||
user = User.find_by(mail: email) unless username =~ CustomRegexp::LOGIN
|
||||
user = User.find_by(login: username) unless email =~ CustomRegexp::EMAIL
|
||||
end
|
||||
contributors << {contributions: commits, name: username, login: username, email: email, id: user&.id}.stringify_keys
|
||||
end
|
||||
file.close
|
||||
|
||||
$redis_cache.set("ProjectMindsporeContributors", contributors.to_json)
|
||||
|
||||
return contributors
|
||||
else
|
||||
return JSON.parse(cache_result)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user