2018-04-19 03:30:41 +08:00
|
|
|
require 'disk_space'
|
2018-04-20 00:19:21 +08:00
|
|
|
|
2018-04-16 16:42:06 +08:00
|
|
|
class Admin::DashboardNextController < Admin::AdminController
|
2018-04-19 03:30:41 +08:00
|
|
|
def index
|
2018-07-20 02:33:11 +08:00
|
|
|
data = AdminDashboardNextIndexData.fetch_cached_stats
|
|
|
|
|
|
|
|
if SiteSetting.version_checks?
|
|
|
|
data.merge!(version_check: DiscourseUpdates.check_version.as_json)
|
|
|
|
end
|
|
|
|
|
|
|
|
render json: data
|
|
|
|
end
|
|
|
|
|
2018-08-07 04:57:40 +08:00
|
|
|
def moderation; end
|
2018-12-14 20:47:59 +08:00
|
|
|
def security; end
|
2018-07-27 02:59:28 +08:00
|
|
|
|
2018-07-20 02:33:11 +08:00
|
|
|
def general
|
|
|
|
data = AdminDashboardNextGeneralData.fetch_cached_stats
|
|
|
|
|
|
|
|
if SiteSetting.enable_backups
|
|
|
|
data[:last_backup_taken_at] = last_backup_taken_at
|
|
|
|
data[:disk_space] = DiskSpace.cached_stats
|
|
|
|
end
|
|
|
|
|
|
|
|
render json: data
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def last_backup_taken_at
|
2018-10-15 09:43:31 +08:00
|
|
|
store = BackupRestore::BackupStore.create
|
|
|
|
|
|
|
|
begin
|
|
|
|
store.latest_file&.last_modified
|
|
|
|
rescue BackupRestore::BackupStore::StorageError
|
|
|
|
nil
|
2018-07-20 02:33:11 +08:00
|
|
|
end
|
2018-04-19 03:30:41 +08:00
|
|
|
end
|
2018-04-16 16:42:06 +08:00
|
|
|
end
|