Merge pull request #8383 from tclaus/show_available_pods
Prepare the backend for generating a list of active pods
This commit is contained in:
commit
77af1b9942
6 changed files with 40 additions and 3 deletions
|
|
@ -43,6 +43,7 @@ We use yarn to install the frontend dependencies now, so you need to have that i
|
|||
* Allow podmins/moderators to see all local public posts to improve moderation [#8232](https://github.com/diaspora/diaspora/pull/8232) [#8320](https://github.com/diaspora/diaspora/pull/8320)
|
||||
* Add support for directly paste images to upload them [#8237](https://github.com/diaspora/diaspora/pull/8237)
|
||||
* Add support for webp images and convert new png/jpg to webp to save space and bandwidth [#8358](https://github.com/diaspora/diaspora/pull/8358)
|
||||
* Show total and active pods count in the pods list for podmins [#8383](https://github.com/diaspora/diaspora/pull/8383)
|
||||
|
||||
# 0.7.18.0
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,25 @@ app.pages.AdminPods = app.views.Base.extend({
|
|||
|
||||
_showMessages: function() {
|
||||
var msgs = document.createDocumentFragment();
|
||||
if (gon.totalCount && gon.totalCount > 0) {
|
||||
let totalPods = $("<div class='alert alert-info' role='alert' />")
|
||||
.append(Diaspora.I18n.t("admin.pods.total", {count: gon.totalCount}));
|
||||
if (gon.activeCount) {
|
||||
if (gon.activeCount === 0) {
|
||||
totalPods
|
||||
.append(" " + Diaspora.I18n.t("admin.pods.none_active"));
|
||||
}
|
||||
if (gon.activeCount === gon.totalCount) {
|
||||
totalPods
|
||||
.append(" " + Diaspora.I18n.t("admin.pods.all_active"));
|
||||
} else {
|
||||
totalPods
|
||||
.append(" " + Diaspora.I18n.t("admin.pods.active", {count: gon.activeCount}));
|
||||
}
|
||||
}
|
||||
msgs.appendChild(totalPods[0]);
|
||||
}
|
||||
|
||||
if( gon.uncheckedCount && gon.uncheckedCount > 0 ) {
|
||||
var unchecked = $("<div class='alert alert-info' role='alert' />")
|
||||
.append(Diaspora.I18n.t("admin.pods.unchecked", {count: gon.uncheckedCount}));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ module Admin
|
|||
gon.unchecked_count = Pod.unchecked.count
|
||||
gon.version_failed_count = Pod.version_failed.count
|
||||
gon.error_count = Pod.check_failed.count
|
||||
|
||||
gon.active_count = Pod.active.count
|
||||
gon.total_count = Pod.count
|
||||
render "admins/pods"
|
||||
end
|
||||
format.mobile { render "admins/pods" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Pod < ApplicationRecord
|
||||
# a pod is active if it is online or was online less than 14 days ago
|
||||
ACTIVE_DAYS = 14.days
|
||||
|
||||
enum status: %i(
|
||||
unchecked
|
||||
no_errors
|
||||
|
|
@ -39,6 +42,10 @@ class Pod < ApplicationRecord
|
|||
where(arel_table[:status].gt(Pod.statuses[:no_errors])).where.not(status: Pod.statuses[:version_failed])
|
||||
}
|
||||
|
||||
scope :active, -> {
|
||||
where(["offline_since is null or offline_since > ?", DateTime.now.utc - ACTIVE_DAYS])
|
||||
}
|
||||
|
||||
validate :not_own_pod
|
||||
|
||||
class << self
|
||||
|
|
@ -73,9 +80,9 @@ class Pod < ApplicationRecord
|
|||
Pod.offline_statuses.include?(Pod.statuses[status])
|
||||
end
|
||||
|
||||
# a pod is active if it is online or was online less than 14 days ago
|
||||
# a pod is active if it is online or was online recently
|
||||
def active?
|
||||
!offline? || offline_since.try {|date| date > DateTime.now.utc - 14.days }
|
||||
!offline? || offline_since.try {|date| date > DateTime.now.utc - ACTIVE_DAYS }
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class PodPresenter < BasePresenter
|
|||
status: status,
|
||||
checked_at: checked_at,
|
||||
response_time: response_time,
|
||||
active: active?,
|
||||
offline: offline?,
|
||||
offline_since: offline_since,
|
||||
created_at: created_at,
|
||||
|
|
|
|||
|
|
@ -70,9 +70,17 @@ en:
|
|||
other: "<%= count %>ms"
|
||||
unknown: "unknown"
|
||||
not_available: "not available"
|
||||
total:
|
||||
one: "There is only one known pod."
|
||||
other: "There are <%= count %> known pods in total."
|
||||
unchecked:
|
||||
one: "There is still one pod that hasn't been checked at all."
|
||||
other: "There are still <%= count %> pods that haven't been checked at all."
|
||||
active:
|
||||
one: "One pod was active recently."
|
||||
other: "<%= count %> pods were active recently."
|
||||
none_active: "None of them were active recently."
|
||||
all_active: "All of them were active recently."
|
||||
version_failed:
|
||||
one: "There is one pod that has no version (old pod, no NodeInfo)."
|
||||
other: "There are <%= count %> pods that have no version (old pods, no NodeInfo)."
|
||||
|
|
|
|||
Loading…
Reference in a new issue