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 Import
|
||||||
import Handler.Commons
|
import Handler.Commons
|
||||||
|
import Database.Bloodhound
|
||||||
|
|
||||||
getAdminR :: Handler Html
|
getAdminR :: Handler Html
|
||||||
getAdminR = do
|
getAdminR = do
|
||||||
|
@ -30,3 +31,23 @@ getAdminR = do
|
||||||
Left (errorMsg, route) -> do
|
Left (errorMsg, route) -> do
|
||||||
setMessage errorMsg
|
setMessage errorMsg
|
||||||
redirect route
|
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/medium/#MediumId/delete AdminMediumDeleteR GET
|
||||||
/admin/comment AdminCommentR GET
|
/admin/comment AdminCommentR GET
|
||||||
/admin/comment/#CommentId AdminCommentDeleteR GET
|
/admin/comment/#CommentId AdminCommentDeleteR GET
|
||||||
|
/admin/repop-search AdminSearchReloadR GET
|
||||||
|
|
||||||
/tag/#Text TagR GET
|
/tag/#Text TagR GET
|
||||||
|
|
||||||
|
|
|
@ -25,3 +25,8 @@ $newline always
|
||||||
<div class="inner">
|
<div class="inner">
|
||||||
<p>
|
<p>
|
||||||
<a href=@{AdminCommentR}>Comments
|
<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