From a70413ceb39c0550d772137f75e7ab0fc38baf8c Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Tue, 31 Aug 2021 22:51:31 +0300 Subject: [PATCH] feat: fix non pictured thread view --- .env | 2 +- repositories/mocks.go | 30 ++++-------------------------- templates/index.html | 5 ++++- 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/.env b/.env index be9d9b2..f727440 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -ENV=release +ENV=debug PORT=3000 POSTGRES_URL=postgresql://localhost/micrach \ No newline at end of file diff --git a/repositories/mocks.go b/repositories/mocks.go index 614e4a4..7789a0f 100644 --- a/repositories/mocks.go +++ b/repositories/mocks.go @@ -84,33 +84,11 @@ func seedDbMocks() { } for _, post := range posts { - Posts.Create(post) + _, err := Posts.Create(post) + if err != nil { + log.Panicln(err) + } } - - // fileSql := ` - // INSERT INTO files (post_id, name, ext, size) - // VALUES ($1, $2, $3, $4) - // ` - // for _, post := range posts { - // if post.ParentID == 0 { - // conn.Query(context.Background(), postSql, post.ID, post.IsParent, nil, post.Title, post.Text, post.IsSage) - // } else { - // conn.Query(context.Background(), postSql, post.ID, post.IsParent, post.ParentID, post.Title, post.Text, post.IsSage) - // } - - // if err != nil { - // log.Panicln(err) - // } - - // for _, file := range post.Files { - // _, err = Db.Pool.Query(context.TODO(), fileSql, file.PostID, file.Name, file.Ext, file.Size) - - // if err != nil { - // log.Panicln(err) - // } - // } - // } - } func SeedMocks() { diff --git a/templates/index.html b/templates/index.html index 77a27c4..5d49d6b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -49,13 +49,16 @@ {{range $Post := .}}
- {{$FirstFile := index $Post.Files 0}} + {{ $length := len $Post.Files }} {{ if gt $length 0 }} + {{$FirstFile := index $Post.Files 0}} Uploaded picture + {{end}} +
{{$Post.Title}}

{{$Post.Text}}