0.2.75
This commit is contained in:
@@ -51,6 +51,10 @@ type adminMembyAccount struct {
|
||||
// themeAllowed take. The console renders that as every box ticked, which is what an
|
||||
// operator who has never touched the page should see.
|
||||
Themes []string `json:"themes"`
|
||||
// WatchTime is what Tracearr says this person has watched. It is zero-valued and
|
||||
// unmatched for a household running no Tracearr, which the console reads as "not
|
||||
// available" rather than as "watched nothing".
|
||||
WatchTime watchTimeSummary `json:"watchTime"`
|
||||
}
|
||||
|
||||
type adminAccountSettings struct {
|
||||
@@ -108,6 +112,14 @@ func (s *Server) handleAdminAccounts(w http.ResponseWriter, r *http.Request) {
|
||||
notifications = map[string]store.NotificationPreferences{}
|
||||
}
|
||||
|
||||
// One grouped query for the whole household rather than one per person: this page grows
|
||||
// with the family, and a per-account read is how a directory becomes slow.
|
||||
identifiers := make([]watchTimeAccount, 0, len(accounts))
|
||||
for _, account := range accounts {
|
||||
identifiers = append(identifiers, watchTimeAccount{ID: account.ID, Username: account.Username})
|
||||
}
|
||||
watchTime := s.watchTimeForAccounts(r.Context(), identifiers)
|
||||
|
||||
result := make([]adminMembyAccount, 0, len(accounts))
|
||||
for _, account := range accounts {
|
||||
pref := preferences[account.ID]
|
||||
@@ -137,8 +149,10 @@ func (s *Server) handleAdminAccounts(w http.ResponseWriter, r *http.Request) {
|
||||
if !savedNotifications {
|
||||
notificationPrefs = store.DefaultNotificationPreferences()
|
||||
}
|
||||
watched, matchedWatchTime := watchTime[account.ID]
|
||||
result = append(result, adminMembyAccount{
|
||||
ID: account.ID, Username: account.Username, CreatedAt: account.CreatedAt,
|
||||
WatchTime: summariseWatchTime(watched, matchedWatchTime),
|
||||
ID: account.ID, Username: account.Username, CreatedAt: account.CreatedAt,
|
||||
Initials: stringPreference(accountSettings.Preferences, "profileInitials"),
|
||||
LastSeen: account.LastSeen, Devices: account.Devices, Settings: accountSettings,
|
||||
Themes: nonNilStrings(themes[account.ID]),
|
||||
|
||||
Reference in New Issue
Block a user