FIX merge dev_devops branch
This commit is contained in:
commit
9477555ebd
|
@ -6,12 +6,8 @@ class ProjectCategoriesController < ApplicationController
|
|||
end
|
||||
|
||||
def group_list
|
||||
# if current_user&.logged?
|
||||
# projects = Project.list_user_projects(current_user.id)
|
||||
# else
|
||||
# projects = Project.visible
|
||||
# end
|
||||
projects = Project.no_anomory_projects.visible
|
||||
@category_group_list = projects.joins(:project_category).group("project_categories.id", "project_categories.name").size
|
||||
@project_categories = ProjectCategory.where('projects_count > 0')
|
||||
# projects = Project.no_anomory_projects.visible
|
||||
# @category_group_list = projects.joins(:project_category).group("project_categories.id", "project_categories.name").size
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,13 +38,23 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def group_type_list
|
||||
# if current_user&.logged?
|
||||
# projects = Project.list_user_projects(current_user.id)
|
||||
# else
|
||||
# projects = Project.visible
|
||||
# end
|
||||
projects = Project.no_anomory_projects.visible
|
||||
@project_group_list = projects.group(:project_type).size
|
||||
project_statics = ProjectStatistic.first
|
||||
|
||||
@project_statics_list = [
|
||||
{
|
||||
project_type: 'common',
|
||||
name: '开源托管项目',
|
||||
projects_count: project_statics&.common_projects_count || 0
|
||||
},
|
||||
{
|
||||
project_type: 'mirror',
|
||||
name: '开源镜像项目',
|
||||
projects_count: project_statics&.mirror_projects_count || 0
|
||||
}
|
||||
]
|
||||
|
||||
# projects = Project.no_anomory_projects.visible
|
||||
# @project_group_list = projects.group(:project_type).size
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -205,4 +205,14 @@ class Project < ApplicationRecord
|
|||
def self.sync_educoder_shixun(url, private_token, page, per_page)
|
||||
SyncEducoderShixunJob.perform_later(url, private_token, page, per_page)
|
||||
end
|
||||
|
||||
def self.update_common_projects_count!
|
||||
ps = ProjectStatistic.first
|
||||
ps.increment!(:common_projects_count) unless ps.blank?
|
||||
end
|
||||
|
||||
def self.update_mirror_projects_count!
|
||||
ps = ProjectStatistic.first
|
||||
ps.increment!(:mirror_projects_count) unless ps.blank?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
class ProjectStatistic < ApplicationRecord
|
||||
end
|
|
@ -12,6 +12,7 @@ class Projects::CreateService < ApplicationService
|
|||
@project = Project.new(project_params)
|
||||
ActiveRecord::Base.transaction do
|
||||
if @project.save!
|
||||
Project.update_common_projects_count!
|
||||
Repositories::CreateService.new(user, @project, repository_params).call
|
||||
else
|
||||
Rails.logger.info("#############___________create_project_erros______###########{@project.errors.messages}")
|
||||
|
|
|
@ -9,6 +9,7 @@ class Projects::MigrateService < ApplicationService
|
|||
def call
|
||||
@project = Project.new(project_params)
|
||||
if @project.save!
|
||||
Project.update_mirror_projects_count!
|
||||
Repositories::MigrateService.new(user, @project, repository_params).call
|
||||
else
|
||||
#
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
json.array! @category_group_list do |category,v|
|
||||
json.id category[0]
|
||||
json.name category[1]
|
||||
json.projects_count v
|
||||
end
|
||||
json.array! @project_categories do |category|
|
||||
json.id category.id
|
||||
json.name category.name
|
||||
json.projects_count category.projects_count
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
json.array! @project_group_list do |type,v|
|
||||
json.project_type type
|
||||
json.name render_zh_project_type(type)
|
||||
json.projects_count v
|
||||
end
|
||||
json.array! @project_statics_list do |static|
|
||||
json.project_type static[:project_type]
|
||||
json.name static[:name]
|
||||
json.projects_count static[:projects_count]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddIndexToProjects < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :projects, :identifier, name: 'index_projects_on_identifier'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
class CreateProjectStatistics < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :project_statistics do |t|
|
||||
t.integer :common_projects_count, :default => 0
|
||||
t.integer :mirror_projects_count, :default => 0
|
||||
t.integer :sync_mirror_projects_count, :default => 0
|
||||
t.integer :commits_total_count, :default => 0
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddIndexForProjectTypeToProjects < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :projects, :project_type
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue