bump sandbox; bin/user-activity
This commit is contained in:
21
bin/user-activity
Executable file
21
bin/user-activity
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONTEXT=${KUBECTL_CONTEXT:-prod}
|
||||
|
||||
kubectl --context "$CONTEXT" exec -n ai postgres-0 -- psql -U postgres -d iceberg -t -A -F $'\t' -c "
|
||||
SELECT u.name,
|
||||
MAX(s.\"createdAt\") as last_login,
|
||||
MAX(s.\"updatedAt\") as last_active
|
||||
FROM \"user\" u
|
||||
LEFT JOIN session s ON s.\"userId\" = u.id
|
||||
GROUP BY u.name
|
||||
ORDER BY last_active DESC NULLS LAST;" 2>/dev/null \
|
||||
| awk -F'\t' '
|
||||
BEGIN {
|
||||
fmt = "%-16s %-24s %-24s\n"
|
||||
printf fmt, "Name", "Last Login", "Last Active"
|
||||
printf fmt, "----------------", "------------------------", "------------------------"
|
||||
}
|
||||
{
|
||||
printf fmt, $1, $2, $3
|
||||
}'
|
||||
Reference in New Issue
Block a user