mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:42:45 +08:00
UX: sort admins and moderators by last seen date on /about page
UX: only show active admins and moderators on /about page
This commit is contained in:
parent
ff8f9dc1c9
commit
c4422fdc13
|
@ -1,7 +1,23 @@
|
|||
import { ajax } from "discourse/lib/ajax";
|
||||
export default Discourse.Route.extend({
|
||||
model() {
|
||||
return ajax("/about.json").then(result => result.about);
|
||||
return ajax("/about.json").then(result => {
|
||||
let activeAdmins = [];
|
||||
let activeModerators = [];
|
||||
const yearAgo = moment()
|
||||
.locale("en")
|
||||
.utc()
|
||||
.subtract(1, "year");
|
||||
result.about.admins.forEach(r => {
|
||||
if (moment(r.last_seen_at) > yearAgo) activeAdmins.push(r);
|
||||
});
|
||||
result.about.moderators.forEach(r => {
|
||||
if (moment(r.last_seen_at) > yearAgo) activeModerators.push(r);
|
||||
});
|
||||
result.about.admins = activeAdmins;
|
||||
result.about.moderators = activeModerators;
|
||||
return result.about;
|
||||
});
|
||||
},
|
||||
|
||||
titleToken() {
|
||||
|
|
|
@ -36,11 +36,13 @@ class About
|
|||
def moderators
|
||||
@moderators ||= User.where(moderator: true, admin: false)
|
||||
.human_users
|
||||
.order(:username_lower)
|
||||
.order("last_seen_at DESC")
|
||||
end
|
||||
|
||||
def admins
|
||||
@admins ||= User.where(admin: true).human_users.order(:username_lower)
|
||||
@admins ||= User.where(admin: true)
|
||||
.human_users
|
||||
.order("last_seen_at DESC")
|
||||
end
|
||||
|
||||
def stats
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
class AboutSerializer < ApplicationSerializer
|
||||
has_many :moderators, serializer: UserNameSerializer, embed: :objects
|
||||
has_many :admins, serializer: UserNameSerializer, embed: :objects
|
||||
|
||||
class UserAboutSerializer < BasicUserSerializer
|
||||
attributes :title, :last_seen_at
|
||||
end
|
||||
|
||||
has_many :moderators, serializer: UserAboutSerializer, embed: :objects
|
||||
has_many :admins, serializer: UserAboutSerializer, embed: :objects
|
||||
|
||||
attributes :stats,
|
||||
:description,
|
||||
|
|
|
@ -21,37 +21,43 @@ export default {
|
|||
id: 3,
|
||||
username: "supermathie",
|
||||
uploaded_avatar_id: 5247,
|
||||
avatar_template: "/images/avatar.png"
|
||||
avatar_template: "/images/avatar.png",
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 32,
|
||||
username: "codinghorror",
|
||||
uploaded_avatar_id: 5297,
|
||||
avatar_template: "/images/avatar.png"
|
||||
avatar_template: "/images/avatar.png",
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 19,
|
||||
username: "eviltrout",
|
||||
uploaded_avatar_id: 5275,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: "neil",
|
||||
uploaded_avatar_id: 5245,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
username: "sam",
|
||||
uploaded_avatar_id: 5243,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 1995,
|
||||
username: "zogstrip",
|
||||
uploaded_avatar_id: 8630,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
}
|
||||
],
|
||||
admins: [
|
||||
|
@ -60,48 +66,56 @@ export default {
|
|||
username: "supermathie",
|
||||
uploaded_avatar_id: 5247,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 32,
|
||||
username: "codinghorror",
|
||||
uploaded_avatar_id: 5297,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 19,
|
||||
username: "eviltrout",
|
||||
uploaded_avatar_id: 5275,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 38,
|
||||
username: "frandallfarmer",
|
||||
uploaded_avatar_id: 5307,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 6626,
|
||||
username: "riking",
|
||||
uploaded_avatar_id: 9779,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: "neil",
|
||||
uploaded_avatar_id: 5245,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
username: "sam",
|
||||
uploaded_avatar_id: 5243,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
},
|
||||
{
|
||||
id: 1995,
|
||||
username: "zogstrip",
|
||||
uploaded_avatar_id: 8630,
|
||||
avatar_template: "/images/avatar.png"
|
||||
last_seen_at: "2019-01-15T06:17:45.799Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user