From aded00daf11019d2a96aae75a2eb7e1288df6a39 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Date: Wed, 14 May 2025 21:07:56 +0330 Subject: [PATCH] Increase post fetch interval and add initial fetch on startup --- .gitignore | 3 ++- cmd/main.go | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 11424f8..bd58fa1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.db -*.sqlite \ No newline at end of file +*.sqlite +build/ \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index c3bdfee..404e826 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -15,7 +15,7 @@ func main() { // Setup AppContext var appContext = helpers.SetupAppContext() - ticker := time.NewTicker(1 * time.Minute) + ticker := time.NewTicker(10 * time.Minute) runFetchPosts := func() { // Get posts @@ -50,6 +50,10 @@ func main() { runFetchPosts() } }() + // Run initial fetch on startup + go func() { + runFetchPosts() + }() // https://seefnasrul.medium.com/create-your-first-go-rest-api-with-jwt-authentication-in-gin-framework-dbe5bda72817 engine := gin.Default()