-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added html striped content for better search
- Loading branch information
1 parent
0fe375b
commit 7ce9997
Showing
5 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
raven/patches/v1_3/update_all_messages_to_include_message_content.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import frappe | ||
from frappe.utils import strip_html_tags | ||
|
||
|
||
def execute(): | ||
update_old_messages_to_include_message_content() | ||
|
||
|
||
def update_old_messages_to_include_message_content(): | ||
''' | ||
Update all old messages to include message content | ||
Message content is required for search | ||
It is basically the message's text content but without any html tags | ||
(this is done to improve search results) | ||
This is a one-time operation, not required for new messages | ||
''' | ||
messages = frappe.db.get_all('Raven Message', fields=[ | ||
'name', 'text', 'message_type']) | ||
for message in messages: | ||
if message.text: | ||
cleaned_text = strip_html_tags(message.text).replace( | ||
'\ufeff', '').replace(' ', ' ') | ||
content = cleaned_text | ||
frappe.db.set_value( | ||
'Raven Message', message.name, 'content', content) | ||
frappe.db.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters