A collection of Custom Bluesky Feeds, including Fresh Feeds, all under one roof

localtesting fix

rimar1337 f2a921b3 adae6219

Changed files
+36 -3
cmd
indexer
+28
cmd/main.go
··· 121 121 false, 122 122 ) 123 123 124 + localrindsFeed, localrindsFeedAliases, err := freshfeeds.NewStaticFeed( 125 + ctx, 126 + feedActorDID, 127 + "localrinds-test", 128 + // This static post is the conversation that sparked this demo repo 129 + []string{"at://did:plc:mn45tewwnse5btfftvd3powc/app.bsky.feed.post/3kgjjhlsnoi2f"}, 130 + db, 131 + "localrinds-test", 132 + false, 133 + ) 134 + 124 135 randomFeed, randomFeedAliases, err := freshfeeds.NewStaticFeed( 125 136 ctx, 126 137 feedActorDID, ··· 208 219 // Add the static feed to the feed generator 209 220 feedRouter.AddFeed(staticFeedAliases, staticFeed) 210 221 222 + feedRouter.AddFeed(localrindsFeedAliases, localrindsFeed) 223 + 211 224 feedRouter.AddFeed(rindsFeedAliases, rindsFeed) 212 225 feedRouter.AddFeed(randomFeedAliases, randomFeed) 213 226 feedRouter.AddFeed(repostsFeedAliases, repostsFeed) ··· 241 254 ep := ginendpoints.NewEndpoints(feedRouter) 242 255 router.GET("/.well-known/did.json", ep.GetWellKnownDID) 243 256 router.GET("/xrpc/app.bsky.feed.describeFeedGenerator", ep.DescribeFeeds) 257 + // Root route: ASCII art and GitHub link 258 + router.GET("/", func(c *gin.Context) { 259 + c.Header("Content-Type", "text/plain; charset=utf-8") 260 + c.String(http.StatusOK, ` ____ _ _ 261 + | _ \(_)_ __ __| |___ 262 + | |_) | | '_ \ / _' / __| 263 + | _ <| | | | | (_| \__ \ 264 + |_| \_\_|_| |_|\__,_|___/ 265 + 266 + bsky feed generator 267 + 268 + Code: https://github.com/rimar1337/rinds 269 + Flagship instance: https://bsky.app/profile/did:plc:mn45tewwnse5btfftvd3powc/feed/rinds 270 + `) 271 + }) 244 272 245 273 // Plug in Authentication Middleware 246 274 auther, err := auth.NewAuth(
+8 -3
indexer/indexer.go
··· 182 182 id SERIAL PRIMARY KEY, 183 183 rel_author TEXT NOT NULL, 184 184 post_uri TEXT NOT NULL, 185 - rel_date BIGINT NOT NULL 185 + rel_date BIGINT NOT NULL, 186 + UNIQUE(rel_author, post_uri) 186 187 ); 187 188 `) 188 189 if err != nil { ··· 347 348 _, err := stmt.Exec(post.RelAuthor, post.PostUri, post.RelDate, post.IsRepost, post.RepostUri, post.ReplyTo) 348 349 if err != nil { 349 350 log.Printf("Error executing statement: %v", err) 351 + log.Printf("Failed INSERT: %+v\nError: %v", post, err) 352 + os.Exit(1) // Exit on error 350 353 } 351 354 } 352 355 ··· 360 363 } 361 364 362 365 func startBatchInsertLikesJob(db *sql.DB) { 363 - ticker := time.NewTicker(1 * time.Second) 366 + ticker := time.NewTicker(batchInterval) 364 367 defer ticker.Stop() 365 368 366 369 for range ticker.C { 367 - if len(likeBatch) > 0 { 370 + if len(likeBatch) >= batchInsertSize { 368 371 batchInsertLikes(db) 369 372 } 370 373 } ··· 392 395 _, err := stmt.Exec(like.RelAuthor, like.PostUri, like.RelDate) 393 396 if err != nil { 394 397 log.Printf("Error executing statement: %v", err) 398 + log.Printf("Failed LIKE INSERT: %+v\nError: %v", like, err) 399 + os.Exit(1) // Exit on error 395 400 } 396 401 } 397 402