mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
feat: remove local seeds
This commit is contained in:
parent
ac006d5f1b
commit
4c48bdb5b5
@ -12,10 +12,6 @@ type PostsRepository struct{}
|
|||||||
var Posts PostsRepository
|
var Posts PostsRepository
|
||||||
|
|
||||||
func (r *PostsRepository) Get(limit, offset int) ([]Post, error) {
|
func (r *PostsRepository) Get(limit, offset int) ([]Post, error) {
|
||||||
if Db.Pool == nil {
|
|
||||||
return PostsDb, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
conn, err := Db.Pool.Acquire(context.TODO())
|
conn, err := Db.Pool.Acquire(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -3,7 +3,6 @@ package repositories
|
|||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
Db "micrach/db"
|
|
||||||
"time"
|
"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() {
|
func seedDb() {
|
||||||
// preparing seed data with parent posts with files
|
// preparing seed data with parent posts with files
|
||||||
var parentPosts []Post
|
var parentPosts []Post
|
||||||
@ -119,10 +108,6 @@ func seedDb() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Seed() {
|
func Seed() {
|
||||||
if Db.Pool != nil {
|
seedDb()
|
||||||
seedDb()
|
|
||||||
} else {
|
|
||||||
seedLocal()
|
|
||||||
}
|
|
||||||
log.Println("mocks - online")
|
log.Println("mocks - online")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user