Public rank change log: sa_rank_log, written on rank changes, listed on the Staff page
This commit is contained in:
parent
861692c534
commit
611b79cdba
11 changed files with 346 additions and 17 deletions
|
|
@ -208,6 +208,39 @@ func (s *Server) publicStaff(w http.ResponseWriter, r *http.Request) {
|
|||
writeJSON(w, http.StatusOK, map[string]any{"groups": groups, "staffOnline": s.serverView(x, st).StaffOnline})
|
||||
}
|
||||
|
||||
type rankChangeView struct {
|
||||
store.RankChange
|
||||
Old *rankView `json:"old,omitempty"`
|
||||
New *rankView `json:"new,omitempty"`
|
||||
}
|
||||
|
||||
// publicRankChanges is the promotions and demotions list, with each rank's label and colour.
|
||||
func (s *Server) publicRankChanges(w http.ResponseWriter, r *http.Request) {
|
||||
lim, off, num := page(r)
|
||||
items, total, err := s.st.RankChanges(r.Context(), lim, off)
|
||||
if err != nil {
|
||||
internal(w, r, err)
|
||||
return
|
||||
}
|
||||
x, err := s.staffIdx(r.Context())
|
||||
if err != nil {
|
||||
internal(w, r, err)
|
||||
return
|
||||
}
|
||||
view := func(g string) *rankView {
|
||||
if g == "" {
|
||||
return nil
|
||||
}
|
||||
rk := s.site.rank(g, x.groupIndex(g))
|
||||
return &rankView{Name: g, Label: rk.Label, Color: rk.Color, Supporter: rk.Supporter}
|
||||
}
|
||||
out := make([]rankChangeView, 0, len(items))
|
||||
for _, c := range items {
|
||||
out = append(out, rankChangeView{RankChange: c, Old: view(c.OldRank), New: view(c.NewRank)})
|
||||
}
|
||||
writeJSON(w, http.StatusOK, newList(out, total, num))
|
||||
}
|
||||
|
||||
func (s *Server) publicPlayer(w http.ResponseWriter, r *http.Request) {
|
||||
steamid := r.PathValue("steamid")
|
||||
if !steam.ValidID(steamid) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue