Merge branch 'standalone_develop' into pre_trustie_server
This commit is contained in:
commit
95ee28b710
|
@ -47,8 +47,13 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def entries
|
def entries
|
||||||
@project.increment!(:visits)
|
@week_project_visit_record, @month_project_visit_record = TimeableVisitRecord.build(@project.id)
|
||||||
CacheAsyncSetJob.perform_later("project_common_service", {visits: 1}, @project.id)
|
if @week_project_visit_record.visits < 300 && @month_project_visit_record.visits < 1000
|
||||||
|
@week_project_visit_record.increment!(:visits)
|
||||||
|
@month_project_visit_record.increment!(:visits)
|
||||||
|
@project.increment!(:visits)
|
||||||
|
CacheAsyncSetJob.perform_later("project_common_service", {visits: 1}, @project.id)
|
||||||
|
end
|
||||||
if @project.educoder?
|
if @project.educoder?
|
||||||
@entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder.repo_name)
|
@entries = Educoder::Repository::Entries::ListService.call(@project&.project_educoder.repo_name)
|
||||||
else
|
else
|
||||||
|
|
|
@ -349,7 +349,7 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
# 通过login参数查询头歌账号信息,注册并登录
|
# 通过login参数查询头歌账号信息,注册并登录
|
||||||
def autologin_register_by_educoder(edu_login)
|
def autologin_register_by_educoder(edu_login)
|
||||||
req_params = { "login" => "#{edu_login}", "private_token" => "hriEn3UwXfJs3PmyXnSH" }
|
req_params = { "login" => "#{edu_login}", "private_token" => "hriEn3UwXfJs3PmyXnqQ" }
|
||||||
api_url= "https://data.educoder.net"
|
api_url= "https://data.educoder.net"
|
||||||
client = Faraday.new(url: api_url)
|
client = Faraday.new(url: api_url)
|
||||||
response = client.public_send("get", "/api/sources/get_user_info_by_login", req_params)
|
response = client.public_send("get", "/api/sources/get_user_info_by_login", req_params)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: timeable_visit_records
|
||||||
|
#
|
||||||
|
# id :integer not null, primary key
|
||||||
|
# time :string(255)
|
||||||
|
# project_id :integer
|
||||||
|
# visits :integer
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_timeable_visit_records_on_project_id (project_id)
|
||||||
|
# index_timeable_visit_records_on_time (time)
|
||||||
|
#
|
||||||
|
|
||||||
|
class TimeableVisitRecord < ApplicationRecord
|
||||||
|
|
||||||
|
belongs_to :project
|
||||||
|
|
||||||
|
def self.build(project_id)
|
||||||
|
week = TimeableVisitRecord.find_or_create_by!(time: Date.today.cweek, project_id: project_id)
|
||||||
|
month = TimeableVisitRecord.find_or_create_by!(time: Date.today.strftime("%Y%m"), project_id: project_id)
|
||||||
|
|
||||||
|
return week, month
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
class CreateTimeableVisitRecords < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :timeable_visit_records do |t|
|
||||||
|
t.string :time
|
||||||
|
t.references :project
|
||||||
|
t.integer :visits, default: 0
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :timeable_visit_records, :time
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,45 @@
|
||||||
|
namespace :update_educoder_user do
|
||||||
|
desc "update educoder user mail phone"
|
||||||
|
task done: :environment do
|
||||||
|
data = User.where("mail like '%***%' or phone like '%***%'")
|
||||||
|
data = User.where(login: ENV['login']) if ENV['login'].present?
|
||||||
|
data.each do |user|
|
||||||
|
begin
|
||||||
|
req_params = { "login" => "#{user.login}", "private_token" => "hriEn3UwXfJs3PmyXnqQ" }
|
||||||
|
api_url = "https://data.educoder.net"
|
||||||
|
client = Faraday.new(url: api_url)
|
||||||
|
response = client.public_send("get", "/api/sources/get_user_info_by_login", req_params)
|
||||||
|
result = JSON.parse(response.body)
|
||||||
|
#查询
|
||||||
|
next if result["status"].to_s != "0"
|
||||||
|
|
||||||
|
# login 邮箱 手机号 姓名 学校/单位
|
||||||
|
user_info = result["data"]
|
||||||
|
Rails.logger.info("user_info====== #{user_info}")
|
||||||
|
login = user_info["login"]
|
||||||
|
email = user_info["mail"]
|
||||||
|
phone = user_info["phone"]
|
||||||
|
real_name = user_info["username"]
|
||||||
|
department_name = user_info["school"]
|
||||||
|
password = "12345678"
|
||||||
|
|
||||||
|
user.update_columns(mail: "#{email}", phone: "#{phone}")
|
||||||
|
|
||||||
|
sync_params = {
|
||||||
|
email: email,
|
||||||
|
login_name: user.login,
|
||||||
|
source_id: 0
|
||||||
|
}
|
||||||
|
interactor = Gitea::User::UpdateInteractor.call(user.login, sync_params)
|
||||||
|
if interactor.success?
|
||||||
|
puts "success user: #{user.id} username:#{user.login}"
|
||||||
|
else
|
||||||
|
puts "error user: #{user.id} username:#{user.login}, error:#{interactor.error.to_s}"
|
||||||
|
end
|
||||||
|
|
||||||
|
rescue Exception => e
|
||||||
|
puts "error user: #{user.id} username:#{user.login}, error:#{e}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue