From 4c48bdb5b5be052bd7c1ea6295ba4ac52366ca27 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Wed, 8 Sep 2021 15:39:09 +0300 Subject: [PATCH] feat: remove local seeds --- repositories/posts_repository.go | 4 ---- repositories/seeds.go | 17 +---------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/repositories/posts_repository.go b/repositories/posts_repository.go index e11c27b..829c325 100644 --- a/repositories/posts_repository.go +++ b/repositories/posts_repository.go @@ -12,10 +12,6 @@ type PostsRepository struct{} var Posts PostsRepository func (r *PostsRepository) Get(limit, offset int) ([]Post, error) { - if Db.Pool == nil { - return PostsDb, nil - } - conn, err := Db.Pool.Acquire(context.TODO()) if err != nil { return nil, err diff --git a/repositories/seeds.go b/repositories/seeds.go index 7e201ce..60ae51b 100644 --- a/repositories/seeds.go +++ b/repositories/seeds.go @@ -3,7 +3,6 @@ package repositories import ( "log" "math/rand" - Db "micrach/db" "time" ) @@ -62,16 +61,6 @@ func getPost(id int, pid *int) Post { } } -var PostsDb = []Post{} - -func seedLocal() { - rand.Seed(time.Now().UnixNano()) - - for i := 1; i < 10; i++ { - PostsDb = append(PostsDb, getPost(i, nil)) - } -} - func seedDb() { // preparing seed data with parent posts with files var parentPosts []Post @@ -119,10 +108,6 @@ func seedDb() { } func Seed() { - if Db.Pool != nil { - seedDb() - } else { - seedLocal() - } + seedDb() log.Println("mocks - online") }