pico
created pr with
96.1
added 96.2
1: bd8d606 = 1: bd8d606 feat: access logs
-: ------- > 2: d247cbd feat: find access logs by pubkey
cmds
checkout latest patchset:
ssh pr.pico.sh print 96 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 96.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 96
Patchset
96.2
feat: find access logs by pubkey
Eric Bower
2025-12-18T00:31:56ZSemantic diff summary
2 added,
1 modified,
0 signature changed,
0 removed
across 3 analyzed files
+1
-0
pkg/db/db.go
#
| ... | ... | @@ -466,6 +466,7 @@ type DB interface { | |
| 466 | 466 | InsertAccessLog(log *AccessLog) error | |
| 467 | 467 | FindAccessLogs(userID string, fromDate *time.Time) ([]*AccessLog, error) | |
| 468 | 468 | FindPubkeysInAccessLogs(userID string) ([]string, error) | |
| 469 | + | FindAccessLogsByPubkey(pubkey string, fromDate *time.Time) ([]*AccessLog, error) | |
| 469 | 470 | ||
| 470 | 471 | Close() error | |
| 471 | 472 | } |
+26
-0
pkg/db/postgres/storage.go
#
| ... | ... | @@ -1967,6 +1967,32 @@ func (me *PsqlDB) FindAccessLogs(userID string, fromDate *time.Time) ([]*db.Acce | |
| 1967 | 1967 | return logs, nil | |
| 1968 | 1968 | } | |
| 1969 | 1969 | ||
| 1970 | + | func (me *PsqlDB) FindAccessLogsByPubkey(pubkey string, fromDate *time.Time) ([]*db.AccessLog, error) { | |
| 1971 | + | logs := []*db.AccessLog{} | |
| 1972 | + | rs, err := me.Db.Query( | |
| 1973 | + | `SELECT id, user_id, service, pubkey, identity, created_at FROM access_logs WHERE pubkey=$1 AND created_at >= $2 ORDER BY created_at DESC`, pubkey, fromDate) | |
| 1974 | + | if err != nil { | |
| 1975 | + | return nil, err | |
| 1976 | + | } | |
| 1977 | + | ||
| 1978 | + | for rs.Next() { | |
| 1979 | + | log := db.AccessLog{} | |
| 1980 | + | err := rs.Scan( | |
| 1981 | + | &log.ID, &log.UserID, &log.Service, &log.Pubkey, &log.Identity, &log.CreatedAt, | |
| 1982 | + | ) | |
| 1983 | + | if err != nil { | |
| 1984 | + | return nil, err | |
| 1985 | + | } | |
| 1986 | + | logs = append(logs, &log) | |
| 1987 | + | } | |
| 1988 | + | ||
| 1989 | + | if rs.Err() != nil { | |
| 1990 | + | return nil, rs.Err() | |
| 1991 | + | } | |
| 1992 | + | ||
| 1993 | + | return logs, nil | |
| 1994 | + | } | |
| 1995 | + | ||
| 1970 | 1996 | func (me *PsqlDB) FindPubkeysInAccessLogs(userID string) ([]string, error) { | |
| 1971 | 1997 | pubkeys := []string{} | |
| 1972 | 1998 | rs, err := me.Db.Query( |
+4
-0
pkg/db/stub/stub.go
#
| ... | ... | @@ -293,6 +293,10 @@ func (me *StubDB) FindAccessLogs(userID string, fromDate *time.Time) ([]*db.Acce | |
| 293 | 293 | return nil, errNotImpl | |
| 294 | 294 | } | |
| 295 | 295 | ||
| 296 | + | func (me *StubDB) FindAccessLogsByPubkey(pubkey string, fromDate *time.Time) ([]*db.AccessLog, error) { | |
| 297 | + | return nil, errNotImpl | |
| 298 | + | } | |
| 299 | + | ||
| 296 | 300 | func (me *StubDB) FindPubkeysInAccessLogs(userID string) ([]string, error) { | |
| 297 | 301 | return []string{}, errNotImpl | |
| 298 | 302 | } |