search index now repopulatable
This commit is contained in:
parent
9d5b140a05
commit
63342563fb
3 changed files with 27 additions and 0 deletions
|
@ -18,6 +18,7 @@ module Handler.Admin where
|
|||
|
||||
import Import
|
||||
import Handler.Commons
|
||||
import Database.Bloodhound
|
||||
|
||||
getAdminR :: Handler Html
|
||||
getAdminR = do
|
||||
|
@ -30,3 +31,23 @@ getAdminR = do
|
|||
Left (errorMsg, route) -> do
|
||||
setMessage errorMsg
|
||||
redirect route
|
||||
|
||||
getAdminSearchReloadR :: Handler Html
|
||||
getAdminSearchReloadR = do
|
||||
adminCheck <- loginIsAdmin
|
||||
case adminCheck of
|
||||
Right _ -> do
|
||||
_ <- runBH' $ deleteIndex $ IndexName "_all"
|
||||
users <- runDB $ selectList [] [Asc UserId]
|
||||
albums <- runDB $ selectList [] [Asc AlbumId]
|
||||
media <- runDB $ selectList [] [Asc MediumId]
|
||||
comments <- runDB $ selectList [] [Asc CommentId]
|
||||
mapM_ (\ u -> putIndexES $ ESUser (entityKey u) (entityVal u)) users
|
||||
mapM_ (\ u -> putIndexES $ ESAlbum (entityKey u) (entityVal u)) albums
|
||||
mapM_ (\ u -> putIndexES $ ESMedium (entityKey u) (entityVal u)) media
|
||||
mapM_ (\ u -> putIndexES $ ESComment (entityKey u) (entityVal u)) comments
|
||||
setMessage "search indices repopulated"
|
||||
redirect AdminR
|
||||
Left (msg, route) -> do
|
||||
setMessage msg
|
||||
redirect route
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
/admin/medium/#MediumId/delete AdminMediumDeleteR GET
|
||||
/admin/comment AdminCommentR GET
|
||||
/admin/comment/#CommentId AdminCommentDeleteR GET
|
||||
/admin/repop-search AdminSearchReloadR GET
|
||||
|
||||
/tag/#Text TagR GET
|
||||
|
||||
|
|
|
@ -25,3 +25,8 @@ $newline always
|
|||
<div class="inner">
|
||||
<p>
|
||||
<a href=@{AdminCommentR}>Comments
|
||||
|
||||
<div id="header" class="item" data-width="400">
|
||||
<div class="inner">
|
||||
<p>
|
||||
<a href=@{AdminSearchReloadR}>Repopulate search index
|
||||
|
|
Loading…
Reference in a new issue