Page Menu
Home
Search
Configure Global Search
Log In
Files
F13101490
algolia_indexing.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1 KB
Subscribers
None
algolia_indexing.py
View Options
import
logging
from
algoliasearch.helpers
import
AlgoliaException
log
=
logging
.
getLogger
(
__name__
)
def
push_updated_user
(
user_to_index
:
dict
):
"""Push an update to the Algolia index when a user item is updated"""
from
pillar.api.utils.algolia
import
index_user_save
try
:
index_user_save
(
user_to_index
)
except
AlgoliaException
as
ex
:
log
.
warning
(
'Unable to push user info to Algolia for user "
%s
", id=
%s
;
%s
'
,
# noqa
user_to_index
.
get
(
'username'
),
user_to_index
.
get
(
'objectID'
),
ex
)
def
index_node_save
(
node_to_index
:
dict
):
from
pillar.api.utils
import
algolia
try
:
algolia
.
index_node_save
(
node_to_index
)
except
AlgoliaException
as
ex
:
log
.
warning
(
'Unable to push node info to Algolia for node
%s
;
%s
'
,
node_to_index
,
ex
)
# noqa
def
index_node_delete
(
delete_id
:
str
):
from
pillar.api.utils
import
algolia
try
:
algolia
.
index_node_delete
(
delete_id
)
except
AlgoliaException
as
ex
:
log
.
warning
(
'Unable to delete node info to Algolia for node
%s
;
%s
'
,
delete_id
,
ex
)
# noqa
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, May 25, 11:13 PM (2 d)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
72/b2/5634f05ee009fa5a01eea0db582b
Attached To
rPS Pillar
Event Timeline
Log In to Comment