pico

created pr with 97.1 on 2025-12-18T04:19:09Z · by c8ef7d19
added 97.2 on 2025-12-18T04:36:52Z · by c8ef7d19
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 -3
checkout any patchset in a patch request:
ssh pr.pico.sh print 97.[rev] | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 97
+68 -68 pkg/db/db.go #
......@@ -127,29 +127,29 @@ func (p *FeedItemData) Scan(value any) error {
127127 }
128128
129129 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:"-"`
150150
151151 // computed
152- IsVirtual bool
152+ IsVirtual bool `db:"-"`
153153 }
154154
155155 type Paginate[T any] struct {
......@@ -158,13 +158,13 @@ type Paginate[T any] struct {
158158 }
159159
160160 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"`
163163 }
164164
165165 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"`
168168 }
169169
170170 type SummaryOpts struct {
......@@ -184,34 +184,34 @@ type SummaryVisits struct {
184184 }
185185
186186 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"`
191191 }
192192
193193 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"`
206206 }
207207
208208 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"`
215215 }
216216
217217 type Pager struct {
......@@ -220,19 +220,19 @@ type Pager struct {
220220 }
221221
222222 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"`
228228 }
229229
230230 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"`
236236 }
237237
238238 type FeatureFlag struct {
......@@ -352,17 +352,17 @@ type UserServiceStats struct {
352352 }
353353
354354 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"`
366366 }
367367
368368 var NameValidator = regexp.MustCompile("^[a-zA-Z0-9]{1,50}$")
Back to top