this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add user count to pds list endpoint (#426)

authored by

Jaz and committed by
GitHub
668f3da4 d47a672f

+56
+21
bgs/admin.go
··· 106 106 EventsSeenSinceStartup uint64 `json:"EventsSeenSinceStartup"` 107 107 IngestRate rateLimit `json:"IngestRate"` 108 108 CrawlRate rateLimit `json:"CrawlRate"` 109 + UserCount int64 `json:"UserCount"` 110 + } 111 + 112 + type UserCount struct { 113 + PDSID uint `gorm:"column:pds"` 114 + UserCount int64 `gorm:"column:user_count"` 109 115 } 110 116 111 117 func (bgs *BGS) handleListPDSs(e echo.Context) error { ··· 118 124 119 125 activePDSHosts := bgs.slurper.GetActiveList() 120 126 127 + var userCounts []UserCount 128 + if err := bgs.db.Model(&User{}). 129 + Select("pds, count(*) as user_count"). 130 + Group("pds"). 131 + Find(&userCounts).Error; err != nil { 132 + return err 133 + } 134 + 135 + // Create a map for fast lookup 136 + userCountMap := make(map[uint]int64) 137 + for _, count := range userCounts { 138 + userCountMap[count.PDSID] = count.UserCount 139 + } 140 + 121 141 for i, p := range pds { 122 142 enrichedPDSs[i].PDS = p 123 143 enrichedPDSs[i].HasActiveConnection = false ··· 133 153 continue 134 154 } 135 155 enrichedPDSs[i].EventsSeenSinceStartup = uint64(m.Counter.GetValue()) 156 + enrichedPDSs[i].UserCount = userCountMap[p.ID] 136 157 137 158 // Get the ingest rate limit for this PDS 138 159 ingestRate := rateLimit{
+34
ts/bgs-dash/src/components/Dash/Dash.tsx
··· 601 601 href="#" 602 602 className="group inline-flex" 603 603 onClick={() => { 604 + setSortField("UserCount"); 605 + setSortOrder(sortOrder === "asc" ? "desc" : "asc"); 606 + }} 607 + > 608 + Users 609 + <span 610 + className={`ml-2 flex-none rounded text-gray-400 ${ 611 + sortField === "UserCount" 612 + ? "group-hover:bg-gray-200" 613 + : "invisible group-hover:visible group-focus:visible" 614 + }`} 615 + > 616 + {sortField === "UserCount" && sortOrder === "asc" ? ( 617 + <ChevronUpIcon className="h-5 w-5" aria-hidden="true" /> 618 + ) : ( 619 + <ChevronDownIcon 620 + className="h-5 w-5" 621 + aria-hidden="true" 622 + /> 623 + )} 624 + </span> 625 + </a> 626 + </th> 627 + <th 628 + scope="col" 629 + className="px-3 py-3.5 text-right text-sm font-semibold text-gray-900 pr-6 whitespace-nowrap" 630 + > 631 + <a 632 + href="#" 633 + className="group inline-flex" 634 + onClick={() => { 604 635 setSortField("EventsSeenSinceStartup"); 605 636 setSortOrder(sortOrder === "asc" ? "desc" : "asc"); 606 637 }} ··· 809 840 </button> 810 841 </div> 811 842 )} 843 + </td> 844 + <td className="whitespace-nowrap px-3 py-2 text-sm text-gray-400 text-center w-8 pr-6"> 845 + {pds.UserCount?.toLocaleString()} 812 846 </td> 813 847 <td className="whitespace-nowrap px-3 py-2 text-sm text-gray-400 text-center w-8 pr-6"> 814 848 {pds.EventsSeenSinceStartup?.toLocaleString()}
+1
ts/bgs-dash/src/models/pds.ts
··· 18 18 EventsSeenSinceStartup?: number; 19 19 IngestRate: RateLimit; 20 20 CrawlRate: RateLimit; 21 + UserCount: number; 21 22 } 22 23 23 24 type PDSKey = keyof PDS;