| @@ -38,10 +38,12 @@ namespace :commit_log_to_db do | |||||
| 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.begin_db_transaction | |||||
| sql = "INSERT INTO commit_logs (`user_id`, `project_id`, `repository_id`, `name`, `full_name`, `commit_id`, `ref`, `message`, `created_at`, `updated_at`) VALUES #{data}" | |||||
| sql_connection.execute(sql) | |||||
| if data.present? | |||||
| sql_connection = ActiveRecord::Base.connection | |||||
| sql_connection.begin_db_transaction | |||||
| sql = "INSERT INTO commit_logs (`user_id`, `project_id`, `repository_id`, `name`, `full_name`, `commit_id`, `ref`, `message`, `created_at`, `updated_at`) VALUES #{data}" | |||||
| sql_connection.execute(sql) | |||||
| end | |||||
| end | end | ||||
| end | end | ||||
| @@ -74,10 +76,12 @@ namespace :commit_log_to_db do | |||||
| 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.begin_db_transaction | |||||
| sql = "INSERT INTO commit_logs (`user_id`, `project_id`, `repository_id`, `name`, `full_name`, `commit_id`, `ref`, `message`, `created_at`, `updated_at`) VALUES #{data}" | |||||
| sql_connection.execute(sql) | |||||
| if data.present? | |||||
| sql_connection = ActiveRecord::Base.connection | |||||
| sql_connection.begin_db_transaction | |||||
| sql = "INSERT INTO commit_logs (`user_id`, `project_id`, `repository_id`, `name`, `full_name`, `commit_id`, `ref`, `message`, `created_at`, `updated_at`) VALUES #{data}" | |||||
| sql_connection.execute(sql) | |||||
| end | |||||
| end | end | ||||
| end | end | ||||