proper updating of indices

This commit is contained in:
nek0 2016-07-12 18:47:55 +02:00
parent 63342563fb
commit 9dd33e88ff
5 changed files with 25 additions and 4 deletions

View file

@ -101,7 +101,7 @@ postAdminAlbumSettingsR albumId = do
, AlbumSamplePic =. albumSamplePic temp , AlbumSamplePic =. albumSamplePic temp
, AlbumSampleWidth =. width , AlbumSampleWidth =. width
] ]
putIndexES (ESAlbum albumId temp) updateIndexES (ESAlbum albumId temp)
setMessage "Album settings changed successfully" setMessage "Album settings changed successfully"
redirect AdminR redirect AdminR
_ -> do _ -> do

View file

@ -75,7 +75,7 @@ postAdminMediumSettingsR mediumId = do
, MediumDescription =. mediumDescription temp , MediumDescription =. mediumDescription temp
, MediumTags =. mediumTags temp , MediumTags =. mediumTags temp
] ]
putIndexES $ ESMedium mediumId temp updateIndexES $ ESMedium mediumId temp
setMessage "Medium settings changed successfully" setMessage "Medium settings changed successfully"
redirect AdminR redirect AdminR
_ -> do _ -> do

View file

@ -117,7 +117,7 @@ postAdminProfileSettingsR ownerId = do
, UserEmail =. userEmail temp , UserEmail =. userEmail temp
, UserAdmin =. userAdmin temp , UserAdmin =. userAdmin temp
] ]
putIndexES $ ESUser ownerId temp updateIndexES $ ESUser ownerId temp
setMessage "User data updated successfully" setMessage "User data updated successfully"
redirect AdminR redirect AdminR
_ -> do _ -> do

View file

@ -115,7 +115,7 @@ postAlbumSettingsR albumId = do
, AlbumSamplePic =. albumSamplePic temp , AlbumSamplePic =. albumSamplePic temp
, AlbumSampleWidth =. width , AlbumSampleWidth =. width
] ]
putIndexES (ESAlbum albumId temp) updateIndexES (ESAlbum albumId temp)
setMessage "Album settings changed succesfully" setMessage "Album settings changed succesfully"
redirect $ AlbumR albumId redirect $ AlbumR albumId
_ -> do _ -> do

View file

@ -146,6 +146,27 @@ deleteIndexES input = do
runBH' $ deleteDocument (IndexName "medium") (MappingName "medium") (DocId $ extractKey mId) runBH' $ deleteDocument (IndexName "medium") (MappingName "medium") (DocId $ extractKey mId)
ESComment cId comment -> ESComment cId comment ->
runBH' $ deleteDocument (IndexName "comment") (MappingName "comment") (DocId $ extractKey cId) runBH' $ deleteDocument (IndexName "comment") (MappingName "comment") (DocId $ extractKey cId)
checkResponseES resp
updateIndexES :: ESInput -> Handler ()
updateIndexES input = do
resp <- case input of
ESUser uId user ->
runBH' $ updateDocument (IndexName "user") (MappingName "user")
defaultIndexDocumentSettings user (DocId $ extractKey uId)
ESAlbum aId album ->
runBH' $ updateDocument (IndexName "album") (MappingName "album")
defaultIndexDocumentSettings album (DocId $ extractKey aId)
ESMedium mId medium ->
runBH' $ updateDocument (IndexName "medium") (MappingName "medium")
defaultIndexDocumentSettings medium (DocId $ extractKey mId)
ESComment cId comment ->
runBH' $ updateDocument (IndexName "comment") (MappingName "comment")
defaultIndexDocumentSettings comment (DocId $ extractKey cId)
checkResponseES resp
checkResponseES :: Reply -> Handler ()
checkResponseES resp =
case statusCode (responseStatus resp) of case statusCode (responseStatus resp) of
201 -> return () 201 -> return ()
200 -> return () 200 -> return ()