MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / ListDistinctUsers

Method ListDistinctUsers

internal/store/postgres/accesslogs.go:112–131  ·  view source on GitHub ↗

ListDistinctUsers 返回最近 since 时间段内出现过的 distinct username(截取 @ 前缀,去重)。

(since time.Time)

Source from the content-addressed store, hash-verified

110
111// ListDistinctUsers 返回最近 since 时间段内出现过的 distinct username(截取 @ 前缀,去重)。
112func (s *AccessLogStore) ListDistinctUsers(since time.Time) ([]string, error) {
113 ctx := context.Background()
114 rows, err := s.db.Query(ctx,
115 `SELECT DISTINCT SPLIT_PART(username, '@', 1) FROM access_logs WHERE created_at >= $1 ORDER BY 1`,
116 since,
117 )
118 if err != nil {
119 return nil, fmt.Errorf("list distinct users: %w", err)
120 }
121 defer rows.Close()
122 var out []string
123 for rows.Next() {
124 var u string
125 if err := rows.Scan(&u); err != nil {
126 return nil, err
127 }
128 out = append(out, u)
129 }
130 return out, rows.Err()
131}
132
133func (s *AccessLogStore) ListUserAnalysis(since, until time.Time) ([]accesslogs.UserAnalysis, error) {
134 ctx := context.Background()

Callers

nothing calls this directly

Calls 4

NextMethod · 0.80
QueryMethod · 0.65
CloseMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected