pico
created pr with
97.1
added 97.2
1: fdc255e = 1: fdc255e refactor: remove unused db methods
2: 3f855f6 = 2: 3f855f6 chore: add tests for postgres db impl
3: 7cd29a6 = 3: 7cd29a6 refactor: use sqlx interface
4: acd449e = 4: acd449e chore: add db tags
5: f6ed0d7 = 5: f6ed0d7 refactor: use sqlx
6: 29035c6 = 6: 29035c6 refactor: replace custom sql functions with sqlx
7: d4ea6d9 = 7: d4ea6d9 refactor: inline all sql queries
-: ------- > 8: 4bd37ed refactor: use `select * from` where possible
cmds
checkout latest patchset:
ssh pr.pico.sh print 97 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 97.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 97
Patchset
97.1
refactor: remove unused db methods
Eric Bower
chore: add tests for postgres db impl
2025-12-18T03:03:10ZEric Bower
refactor: use sqlx interface
2025-12-18T03:17:57ZEric Bower
→ chore: add db tags
2025-12-18T03:27:57ZEric Bower
refactor: use sqlx
2025-12-18T03:31:25ZEric Bower
refactor: replace custom sql functions with sqlx
2025-12-18T03:43:01ZEric Bower
refactor: inline all sql queries
2025-12-18T03:57:00ZEric Bower
2025-12-18T04:02:50Z
chore: add db tags
Eric Bower
2025-12-18T03:31:25ZSemantic diff summary
0 added,
9 modified,
0 signature changed,
0 removed
across 1 analyzed file
pkg/db/db.go
-
type_declarationPostmodified -
type_declarationVisitIntervalmodified -
type_declarationVisitUrlmodified -
type_declarationPostAnalyticsmodified -
type_declarationAnalyticsVisitsmodified -
type_declarationAccessLogmodified -
type_declarationFeedItemmodified -
type_declarationTokenmodified -
type_declarationTunsEventLogmodified
+68
-68
pkg/db/db.go
#
| ... | ... | @@ -127,29 +127,29 @@ func (p *FeedItemData) Scan(value any) error { | |
| 127 | 127 | } | |
| 128 | 128 | ||
| 129 | 129 | type Post struct { | |
| 130 | - | ID string `json:"id"` | |
| 131 | - | UserID string `json:"user_id"` | |
| 132 | - | Filename string `json:"filename"` | |
| 133 | - | Slug string `json:"slug"` | |
| 134 | - | Title string `json:"title"` | |
| 135 | - | Text string `json:"text"` | |
| 136 | - | Description string `json:"description"` | |
| 137 | - | CreatedAt *time.Time `json:"created_at"` | |
| 138 | - | PublishAt *time.Time `json:"publish_at"` | |
| 139 | - | Username string `json:"username"` | |
| 140 | - | UpdatedAt *time.Time `json:"updated_at"` | |
| 141 | - | ExpiresAt *time.Time `json:"expires_at"` | |
| 142 | - | Hidden bool `json:"hidden"` | |
| 143 | - | Views int `json:"views"` | |
| 144 | - | Space string `json:"space"` | |
| 145 | - | Shasum string `json:"shasum"` | |
| 146 | - | FileSize int `json:"file_size"` | |
| 147 | - | MimeType string `json:"mime_type"` | |
| 148 | - | Data PostData `json:"data"` | |
| 149 | - | Tags []string `json:"tags"` | |
| 130 | + | ID string `json:"id" db:"id"` | |
| 131 | + | UserID string `json:"user_id" db:"user_id"` | |
| 132 | + | Filename string `json:"filename" db:"filename"` | |
| 133 | + | Slug string `json:"slug" db:"slug"` | |
| 134 | + | Title string `json:"title" db:"title"` | |
| 135 | + | Text string `json:"text" db:"text"` | |
| 136 | + | Description string `json:"description" db:"description"` | |
| 137 | + | CreatedAt *time.Time `json:"created_at" db:"created_at"` | |
| 138 | + | PublishAt *time.Time `json:"publish_at" db:"publish_at"` | |
| 139 | + | Username string `json:"username" db:"name"` | |
| 140 | + | UpdatedAt *time.Time `json:"updated_at" db:"updated_at"` | |
| 141 | + | ExpiresAt *time.Time `json:"expires_at" db:"expires_at"` | |
| 142 | + | Hidden bool `json:"hidden" db:"hidden"` | |
| 143 | + | Views int `json:"views" db:"views"` | |
| 144 | + | Space string `json:"space" db:"cur_space"` | |
| 145 | + | Shasum string `json:"shasum" db:"shasum"` | |
| 146 | + | FileSize int `json:"file_size" db:"file_size"` | |
| 147 | + | MimeType string `json:"mime_type" db:"mime_type"` | |
| 148 | + | Data PostData `json:"data" db:"data"` | |
| 149 | + | Tags []string `json:"tags" db:"-"` | |
| 150 | 150 | ||
| 151 | 151 | // computed | |
| 152 | - | IsVirtual bool | |
| 152 | + | IsVirtual bool `db:"-"` | |
| 153 | 153 | } | |
| 154 | 154 | ||
| 155 | 155 | type Paginate[T any] struct { |
| ... | ... | @@ -158,13 +158,13 @@ type Paginate[T any] struct { | |
| 158 | 158 | } | |
| 159 | 159 | ||
| 160 | 160 | type VisitInterval struct { | |
| 161 | - | Interval *time.Time `json:"interval"` | |
| 162 | - | Visitors int `json:"visitors"` | |
| 161 | + | Interval *time.Time `json:"interval" db:"interval"` | |
| 162 | + | Visitors int `json:"visitors" db:"visitors"` | |
| 163 | 163 | } | |
| 164 | 164 | ||
| 165 | 165 | type VisitUrl struct { | |
| 166 | - | Url string `json:"url"` | |
| 167 | - | Count int `json:"count"` | |
| 166 | + | Url string `json:"url" db:"url"` | |
| 167 | + | Count int `json:"count" db:"count"` | |
| 168 | 168 | } | |
| 169 | 169 | ||
| 170 | 170 | type SummaryOpts struct { |
| ... | ... | @@ -184,34 +184,34 @@ type SummaryVisits struct { | |
| 184 | 184 | } | |
| 185 | 185 | ||
| 186 | 186 | type PostAnalytics struct { | |
| 187 | - | ID string | |
| 188 | - | PostID string | |
| 189 | - | Views int | |
| 190 | - | UpdateAt *time.Time | |
| 187 | + | ID string `json:"id" db:"id"` | |
| 188 | + | PostID string `json:"post_id" db:"post_id"` | |
| 189 | + | Views int `json:"views" db:"views"` | |
| 190 | + | UpdateAt *time.Time `json:"updated_at" db:"updated_at"` | |
| 191 | 191 | } | |
| 192 | 192 | ||
| 193 | 193 | type AnalyticsVisits struct { | |
| 194 | - | ID string `json:"id"` | |
| 195 | - | UserID string `json:"user_id"` | |
| 196 | - | ProjectID string `json:"project_id"` | |
| 197 | - | PostID string `json:"post_id"` | |
| 198 | - | Namespace string `json:"namespace"` | |
| 199 | - | Host string `json:"host"` | |
| 200 | - | Path string `json:"path"` | |
| 201 | - | IpAddress string `json:"ip_address"` | |
| 202 | - | UserAgent string `json:"user_agent"` | |
| 203 | - | Referer string `json:"referer"` | |
| 204 | - | Status int `json:"status"` | |
| 205 | - | ContentType string `json:"content_type"` | |
| 194 | + | ID string `json:"id" db:"id"` | |
| 195 | + | UserID string `json:"user_id" db:"user_id"` | |
| 196 | + | ProjectID string `json:"project_id" db:"project_id"` | |
| 197 | + | PostID string `json:"post_id" db:"post_id"` | |
| 198 | + | Namespace string `json:"namespace" db:"namespace"` | |
| 199 | + | Host string `json:"host" db:"host"` | |
| 200 | + | Path string `json:"path" db:"path"` | |
| 201 | + | IpAddress string `json:"ip_address" db:"ip_address"` | |
| 202 | + | UserAgent string `json:"user_agent" db:"user_agent"` | |
| 203 | + | Referer string `json:"referer" db:"referer"` | |
| 204 | + | Status int `json:"status" db:"status"` | |
| 205 | + | ContentType string `json:"content_type" db:"content_type"` | |
| 206 | 206 | } | |
| 207 | 207 | ||
| 208 | 208 | type AccessLog struct { | |
| 209 | - | ID string `json:"id"` | |
| 210 | - | UserID string `json:"user_id"` | |
| 211 | - | Service string `json:"service"` | |
| 212 | - | Pubkey string `json:"pubkey"` | |
| 213 | - | Identity string `json:"identity"` | |
| 214 | - | CreatedAt *time.Time `json:"created_at"` | |
| 209 | + | ID string `json:"id" db:"id"` | |
| 210 | + | UserID string `json:"user_id" db:"user_id"` | |
| 211 | + | Service string `json:"service" db:"service"` | |
| 212 | + | Pubkey string `json:"pubkey" db:"pubkey"` | |
| 213 | + | Identity string `json:"identity" db:"identity"` | |
| 214 | + | CreatedAt *time.Time `json:"created_at" db:"created_at"` | |
| 215 | 215 | } | |
| 216 | 216 | ||
| 217 | 217 | type Pager struct { |
| ... | ... | @@ -220,19 +220,19 @@ type Pager struct { | |
| 220 | 220 | } | |
| 221 | 221 | ||
| 222 | 222 | type FeedItem struct { | |
| 223 | - | ID string | |
| 224 | - | PostID string | |
| 225 | - | GUID string | |
| 226 | - | Data FeedItemData | |
| 227 | - | CreatedAt *time.Time | |
| 223 | + | ID string `json:"id" db:"id"` | |
| 224 | + | PostID string `json:"post_id" db:"post_id"` | |
| 225 | + | GUID string `json:"guid" db:"guid"` | |
| 226 | + | Data FeedItemData `json:"data" db:"data"` | |
| 227 | + | CreatedAt *time.Time `json:"created_at" db:"created_at"` | |
| 228 | 228 | } | |
| 229 | 229 | ||
| 230 | 230 | type Token struct { | |
| 231 | - | ID string `json:"id"` | |
| 232 | - | UserID string `json:"user_id"` | |
| 233 | - | Name string `json:"name"` | |
| 234 | - | CreatedAt *time.Time `json:"created_at"` | |
| 235 | - | ExpiresAt *time.Time `json:"expires_at"` | |
| 231 | + | ID string `json:"id" db:"id"` | |
| 232 | + | UserID string `json:"user_id" db:"user_id"` | |
| 233 | + | Name string `json:"name" db:"name"` | |
| 234 | + | CreatedAt *time.Time `json:"created_at" db:"created_at"` | |
| 235 | + | ExpiresAt *time.Time `json:"expires_at" db:"expires_at"` | |
| 236 | 236 | } | |
| 237 | 237 | ||
| 238 | 238 | type FeatureFlag struct { |
| ... | ... | @@ -352,17 +352,17 @@ type UserServiceStats struct { | |
| 352 | 352 | } | |
| 353 | 353 | ||
| 354 | 354 | type TunsEventLog struct { | |
| 355 | - | ID string `json:"id"` | |
| 356 | - | ServerID string `json:"server_id"` | |
| 357 | - | Time *time.Time `json:"time"` | |
| 358 | - | User string `json:"user"` | |
| 359 | - | UserId string `json:"user_id"` | |
| 360 | - | RemoteAddr string `json:"remote_addr"` | |
| 361 | - | EventType string `json:"event_type"` | |
| 362 | - | TunnelID string `json:"tunnel_id"` | |
| 363 | - | TunnelType string `json:"tunnel_type"` | |
| 364 | - | ConnectionType string `json:"connection_type"` | |
| 365 | - | CreatedAt *time.Time `json:"created_at"` | |
| 355 | + | ID string `json:"id" db:"id"` | |
| 356 | + | ServerID string `json:"server_id" db:"server_id"` | |
| 357 | + | Time *time.Time `json:"time" db:"time"` | |
| 358 | + | User string `json:"user" db:"user"` | |
| 359 | + | UserId string `json:"user_id" db:"user_id"` | |
| 360 | + | RemoteAddr string `json:"remote_addr" db:"remote_addr"` | |
| 361 | + | EventType string `json:"event_type" db:"event_type"` | |
| 362 | + | TunnelID string `json:"tunnel_id" db:"tunnel_id"` | |
| 363 | + | TunnelType string `json:"tunnel_type" db:"tunnel_type"` | |
| 364 | + | ConnectionType string `json:"connection_type" db:"connection_type"` | |
| 365 | + | CreatedAt *time.Time `json:"created_at" db:"created_at"` | |
| 366 | 366 | } | |
| 367 | 367 | ||
| 368 | 368 | var NameValidator = regexp.MustCompile("^[a-zA-Z0-9]{1,50}$") |