This commit is contained in:
BoHung Chiu 2022-05-16 21:54:51 +08:00
parent 039b3cd591
commit 2779a3bf52
3 changed files with 8 additions and 7 deletions

View File

@ -2,7 +2,7 @@
class Admin::RegisteredSitesController < OrbitAdminController
before_action ->(module_app = @app_title) { set_variables module_app }
def index
@registeredsites = RegisteredSite.all.order_by(sort)
@registeredsites = RegisteredSite.where(:not_viewed.ne=>true).order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag")).desc(:created_at)
@table_fields = table_fields
@ -47,7 +47,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
def get_select_box
tags = @module_app.tags.map{|v| v}
categories = @module_app.categories.enabled.map{|v| v}
sites = RegisteredSite.all.collect{|v1| [v1,v1.tags,v1.category]}
sites = RegisteredSite.where(:not_viewed.ne=>true).collect{|v1| [v1,v1.tags,v1.category]}
@sites_order_by_tags = tags.map{|v| {v=>sites.select{|v1| v1[1].include? v}.map{|v2| v2[0]}}}
@sites_order_by_tags << {'no_tag'=>sites.select{|v1| v1[1]== []}.map{|v2| v2[0]}}
@sites_order_by_cats = categories.map{|v| {v=>sites.select{|v1| v1[2]== v}.map{|v2| v2[0]}}}
@ -160,10 +160,10 @@ class Admin::RegisteredSitesController < OrbitAdminController
tp.status = 'running'
tp.save
Thread.new do
count = RegisteredSite.where(:is_hidden.ne=>true).count
count = RegisteredSite.where(:is_hidden.ne=>true, :not_viewed.ne=>true).count
batch_l = (count/50.0).ceil
(1..batch_l).each do |v|
sites = RegisteredSite.where(:is_hidden.ne=>true).sort_by{|v| v.id}[(v-1)*50..(v*50)]
sites = RegisteredSite.where(:is_hidden.ne=>true, :not_viewed.ne=>true).sort_by{|v| v.id}[(v-1)*50..(v*50)]
sites.each do |site|
begin
update_status(site)
@ -442,7 +442,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
end
end
def bundle_update_remote_show
@registeredsites = RegisteredSite.all.order_by(sort)
@registeredsites = RegisteredSite.where(:not_viewed.ne=>true).order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag")).desc(:created_at)
@table_fields = table_fields_for_bundle_update
@ -504,7 +504,7 @@ class Admin::RegisteredSitesController < OrbitAdminController
end
@table_fields = table_fields
@registeredsites = RegisteredSite.all.order_by(sort)
@registeredsites = RegisteredSite.where(:not_viewed.ne=>true).order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag")).desc(:created_at)
@registeredsites = search_data(@registeredsites,[:title,:site_domain]).page(params[:page]).per(10)

View File

@ -14,6 +14,7 @@ class RegisteredSite
field :site_confirmed, type: Boolean, :default => false
field :confirmation_token
field :is_hidden,type: Boolean,:default => false
field :not_viewed,type: Boolean,:default => false
has_many :bundle_update_logs
has_many :site_logs
has_many :installed_modules

View File

@ -12,7 +12,7 @@
</thead>
<tbody>
<% @registeredsites.each_with_index do |site,index1| %>
<% status = site.is_hidden == true ? 'is_hidden' : site.bundle_update_logs.first.status
<% status = site.is_hidden == true ? 'is_hidden' : site.bundle_update_logs.first.status rescue ''
if status == 'failed'
status = 'error'
elsif status == 'finish'