tangled
alpha
login
or
join now
edavis.dev
/
bsky-feeds
1
fork
atom
this repo has no description
1
fork
atom
overview
issues
pulls
pipelines
feat: move post trimming out of the goroutine
Eric Davis
1 year ago
338f76e1
f82adf01
+4
-17
1 changed file
expand all
collapse all
unified
split
pkg
mostliked
handler.go
+4
-17
pkg/mostliked/handler.go
···
36
36
Transferred int
37
37
}
38
38
39
39
-
func trimPostsTable(ctx context.Context, queries *db.Queries) {
40
40
-
ticker := time.NewTicker(1 * time.Minute)
41
41
-
defer ticker.Stop()
42
42
-
43
43
-
for {
44
44
-
select {
45
45
-
case <-ticker.C:
46
46
-
log.Printf("clearing expired posts\n")
47
47
-
if err := queries.TrimPosts(ctx); err != nil {
48
48
-
log.Printf("error clearing expired posts: %v\n", err)
49
49
-
}
50
50
-
}
51
51
-
}
52
52
-
}
53
53
-
54
39
func findDetectableText(post appbsky.FeedPost) string {
55
40
// if we have text, detect against that
56
41
// no text but we do have images, detect against first alt text
···
92
77
FromLanguages(languages...).
93
78
WithPreloadedLanguageModels().
94
79
Build()
95
95
-
96
96
-
go trimPostsTable(ctx, queries)
97
80
98
81
var (
99
82
dbTx *sql.Tx
···
191
174
192
175
eventCount += 1
193
176
if eventCount%1000 == 0 {
177
177
+
if err := queriesTx.TrimPosts(ctx); err != nil {
178
178
+
log.Printf("error clearing expired posts: %v\n", err)
179
179
+
}
180
180
+
194
181
if err := dbTx.Commit(); err != nil {
195
182
log.Printf("commit failed: %v\n", err)
196
183
}