2018-04-18 15:30:41 -04:00
|
|
|
require 'disk_space'
|
2018-04-19 12:19:21 -04:00
|
|
|
|
2018-04-16 04:42:06 -04:00
|
|
|
class Admin::DashboardNextController < Admin::AdminController
|
2018-04-18 15:30:41 -04:00
|
|
|
def index
|
2018-07-19 14:33:11 -04: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-06 16:57:40 -04:00
|
|
|
def moderation; end
|
2018-07-26 14:59:28 -04:00
|
|
|
|
2018-07-19 14:33:11 -04: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-14 21:43:31 -04:00
|
|
|
store = BackupRestore::BackupStore.create
|
|
|
|
|
|
|
|
begin
|
|
|
|
store.latest_file&.last_modified
|
|
|
|
rescue BackupRestore::BackupStore::StorageError
|
|
|
|
nil
|
2018-07-19 14:33:11 -04:00
|
|
|
end
|
2018-04-18 15:30:41 -04:00
|
|
|
end
|
2018-04-16 04:42:06 -04:00
|
|
|
end
|