proper updating of indices
This commit is contained in:
parent
63342563fb
commit
9dd33e88ff
5 changed files with 25 additions and 4 deletions
|
@ -101,7 +101,7 @@ postAdminAlbumSettingsR albumId = do
|
|||
, AlbumSamplePic =. albumSamplePic temp
|
||||
, AlbumSampleWidth =. width
|
||||
]
|
||||
putIndexES (ESAlbum albumId temp)
|
||||
updateIndexES (ESAlbum albumId temp)
|
||||
setMessage "Album settings changed successfully"
|
||||
redirect AdminR
|
||||
_ -> do
|
||||
|
|
|
@ -75,7 +75,7 @@ postAdminMediumSettingsR mediumId = do
|
|||
, MediumDescription =. mediumDescription temp
|
||||
, MediumTags =. mediumTags temp
|
||||
]
|
||||
putIndexES $ ESMedium mediumId temp
|
||||
updateIndexES $ ESMedium mediumId temp
|
||||
setMessage "Medium settings changed successfully"
|
||||
redirect AdminR
|
||||
_ -> do
|
||||
|
|
|
@ -117,7 +117,7 @@ postAdminProfileSettingsR ownerId = do
|
|||
, UserEmail =. userEmail temp
|
||||
, UserAdmin =. userAdmin temp
|
||||
]
|
||||
putIndexES $ ESUser ownerId temp
|
||||
updateIndexES $ ESUser ownerId temp
|
||||
setMessage "User data updated successfully"
|
||||
redirect AdminR
|
||||
_ -> do
|
||||
|
|
|
@ -115,7 +115,7 @@ postAlbumSettingsR albumId = do
|
|||
, AlbumSamplePic =. albumSamplePic temp
|
||||
, AlbumSampleWidth =. width
|
||||
]
|
||||
putIndexES (ESAlbum albumId temp)
|
||||
updateIndexES (ESAlbum albumId temp)
|
||||
setMessage "Album settings changed succesfully"
|
||||
redirect $ AlbumR albumId
|
||||
_ -> do
|
||||
|
|
|
@ -146,6 +146,27 @@ deleteIndexES input = do
|
|||
runBH' $ deleteDocument (IndexName "medium") (MappingName "medium") (DocId $ extractKey mId)
|
||||
ESComment cId comment ->
|
||||
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
|
||||
201 -> return ()
|
||||
200 -> return ()
|
||||
|
|
Loading…
Reference in a new issue