diff of 4c9e28966744db6e93f6eefb74c1d7acc4666a45
4c9e28966744db6e93f6eefb74c1d7acc4666a45
diff --git a/elm-frontti/src/Article.elm b/elm-frontti/src/Article.elm
index 24a371c..565c4b4 100644
--- a/elm-frontti/src/Article.elm
+++ b/elm-frontti/src/Article.elm
@@ -21,11 +21,9 @@ import Time
-- "comments": [],
-- "amount-of-comments": 0,
-- "title": "Testi Posti",
--- "prev-post-id": null,
-- "id": 1,
-- "versions": [],
-- "version": null,
--- "next-post-id": null,
-- "created_at": "2020-10-16T07:52:59Z"
-- }
@@ -44,11 +42,9 @@ type alias Article =
, comments : Maybe (List String)
-- , amount_of_comments : Int
, title : String
- , pre_post_id : Maybe Int
, id : Maybe Int
, versions: Maybe (List Int)
, version : Maybe Int
- -- , next_post_id: Maybe Int
, created_at: Maybe Time.Posix
}
@@ -63,7 +59,6 @@ encode article =
Just comments -> comments
Nothing -> [])))
, ( "title", string article.title)
- , ( "pre_post_id", (maybe int) article.pre_post_id)
, ( "id", (maybe int) article.id)
, ( "version", (maybe int) article.version)
, ( "created_at", (maybe iso8601) article.created_at)
@@ -78,11 +73,9 @@ contentDecoder = Decode.field "content" Decode.string
commentsDecoder = Decode.maybe (Decode.field "comments" (Decode.list Decode.string))
-- amount_of_commentsDecoder = Decode.field "amount-of-comments" Decode.int
titleDecoder = Decode.field "title" Decode.string
-pre_post_idDecoder = Decode.maybe (Decode.field "prev-post-id" Decode.int)
idDecoder = Decode.maybe ( Decode.field "id" Decode.int)
versionsDecoder = Decode.maybe (Decode.field "versions" (Decode.list Decode.int))
versionDecoder = Decode.maybe (Decode.field "version" Decode.int)
--- next_post_idDecoder = Decode.field "next-post-id" (Decode.maybe Decode.int)
created_atDecoder = Decode.field "created_at" (Decode.maybe Extra.iso8601)
creator_Decoder = Decode.field "creator" creatorDecoder
@@ -95,7 +88,6 @@ articleDecoder =
|> decodeApply contentDecoder
|> decodeApply commentsDecoder
|> decodeApply titleDecoder
- |> decodeApply pre_post_idDecoder
|> decodeApply idDecoder
|> decodeApply versionsDecoder
|> decodeApply versionDecoder
diff --git a/elm-frontti/src/Main.elm b/elm-frontti/src/Main.elm
index 82c03da..4dc3561 100644
--- a/elm-frontti/src/Main.elm
+++ b/elm-frontti/src/Main.elm
@@ -205,7 +205,7 @@ update msg model =
({ model | loginState = LoggedIn user
, postEditorSettings = Just (PostEditorSettings
(Maybe.withDefault
- (Article.Article (C.Creator user.username user.nickname user.img_location) [""] "" Nothing "New post" Nothing Nothing (Just []) Nothing Nothing)
+ (Article.Article (C.Creator user.username user.nickname user.img_location) [""] "" Nothing "New post" Nothing (Just []) Nothing Nothing)
model.postFromLocalStorage)
"" False)}
, Cmd.none)
@@ -429,7 +429,7 @@ update msg model =
LoggedIn user ->
({ model | postEditorSettings = Just (PostEditorSettings
(Maybe.withDefault
- (Article.Article (C.Creator user.username user.nickname user.img_location) [""] "" Nothing "New post" Nothing Nothing (Just []) Nothing Nothing)
+ (Article.Article (C.Creator user.username user.nickname user.img_location) [""] "" Nothing "New post" Nothing (Just []) Nothing Nothing)
model.postFromLocalStorage)
"" False)}
, clearPostFromLS ())
diff --git a/resources/sql/post-fns.sql b/resources/sql/post-fns.sql
index e0fa7bf..68ad2e1 100644
--- a/resources/sql/post-fns.sql
+++ b/resources/sql/post-fns.sql
@@ -26,20 +26,6 @@ FROM blog.Post_History
WHERE ID = :post-id AND NOT tags ? 'hidden'
ORDER BY version ASC;
--- name: next-post-id
-SELECT p.ID
-FROM blog.Post p
-WHERE p.ID < :post-id AND NOT p.tags ? 'hidden'
-ORDER BY p.ID DESC
-LIMIT 1;
-
--- name: prev-post-id
-SELECT p.ID
-FROM blog.Post p
-WHERE p.ID > :post-id AND NOT p.tags ? 'hidden'
-ORDER BY p.ID ASC
-LIMIT 1;
-
-- name: get-by-id*
-- returns: :array-hash
SELECT p.ID,
@@ -54,10 +40,8 @@ SELECT p.ID,
u.Nickname,
'img_location',
u.Img_location) as "creator",
- null as "prev-post-id",
'[]'::json as "versions",
- null as "version",
- null as "next-post-id"
+ null as "version"
FROM blog.Post p
JOIN blog.Users u ON u.ID = p.creator_id
WHERE p.ID = $1 AND (NOT p.tags ? 'hidden' OR (p.tags ? 'hidden' AND $2))
@@ -73,9 +57,7 @@ SELECT p.ID, p.Title, p.created_at, p.Content, p.tags, p.version, 0 AS "amount-o
u.Nickname,
'img_location',
u.Img_location) as "creator",
- null as "prev-post-id",
- '[]'::json as "versions",
- null as "next-post-id"
+ '[]'::json as "versions"
FROM blog.Post_History p
JOIN blog.Users u ON u.ID = p.creator_id
WHERE p.ID = $1 AND p.version = $2 AND not tags ? 'hidden';