rake commit_log_to_db 用户不存在
This commit is contained in:
parent
ffea285962
commit
b8e31b8d0b
|
@ -27,10 +27,11 @@ namespace :commit_log_to_db do
|
||||||
ref = "master"
|
ref = "master"
|
||||||
commit_message = commit['commit']['message'].to_s.gsub("/n","")
|
commit_message = commit['commit']['message'].to_s.gsub("/n","")
|
||||||
user = User.find_by(mail: commiter['email'])
|
user = User.find_by(mail: commiter['email'])
|
||||||
|
user_id = user&.id || 1
|
||||||
commit_date = Time.parse(commit['commit']['author']['date'])
|
commit_date = Time.parse(commit['commit']['author']['date'])
|
||||||
commit_date_str = commit_date.strftime("%a %b %d %H:%M:%S")
|
commit_date_str = commit_date.strftime("%a %b %d %H:%M:%S")
|
||||||
|
|
||||||
data += "(#{user&.id},#{project.id},#{project.repository&.id},'#{project.identifier}','#{project.owner.name}/#{project.identifier}','#{commit_sha}','#{ref}',\"#{commit_message}\",'#{commit_date_str}','#{commit_date_str}'),"
|
data += "(#{user_id},#{project.id},#{project.repository&.id},'#{project.identifier}','#{project.owner.name}/#{project.identifier}','#{commit_sha}','#{ref}',\"#{commit_message}\",'#{commit_date_str}','#{commit_date_str}'),"
|
||||||
end
|
end
|
||||||
data = data[0,data.length-1]
|
data = data[0,data.length-1]
|
||||||
sql_connection = ActiveRecord::Base.connection
|
sql_connection = ActiveRecord::Base.connection
|
||||||
|
@ -61,10 +62,11 @@ namespace :commit_log_to_db do
|
||||||
ref = "master"
|
ref = "master"
|
||||||
commit_message = commit['commit']['message'].to_s.gsub("/n","")
|
commit_message = commit['commit']['message'].to_s.gsub("/n","")
|
||||||
user = User.find_by(mail: commiter['email'])
|
user = User.find_by(mail: commiter['email'])
|
||||||
|
user_id = user&.id || 1
|
||||||
commit_date = Time.parse(commit['commit']['author']['date'])
|
commit_date = Time.parse(commit['commit']['author']['date'])
|
||||||
commit_date_str = commit_date.strftime("%Y-%m-%d %H:%M:%S")
|
commit_date_str = commit_date.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
data += "(#{user&.id},#{project.id},#{project.repository&.id},'#{project.identifier}','#{project.owner.name}/#{project.identifier}','#{commit_sha}','#{ref}',\"#{commit_message}\",'#{commit_date_str}','#{commit_date_str}'),"
|
data += "(#{user_id},#{project.id},#{project.repository&.id},'#{project.identifier}','#{project.owner.name}/#{project.identifier}','#{commit_sha}','#{ref}',\"#{commit_message}\",'#{commit_date_str}','#{commit_date_str}'),"
|
||||||
end
|
end
|
||||||
data = data[0,data.length-1]
|
data = data[0,data.length-1]
|
||||||
sql_connection = ActiveRecord::Base.connection
|
sql_connection = ActiveRecord::Base.connection
|
||||||
|
|
Loading…
Reference in New Issue