2020-07-05 14:57:52 +02:00
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from django.db import connection
|
2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
2020-07-05 14:57:52 +02:00
|
|
|
|
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
|
|
|
|
|
|
|
|
|
|
|
class Command(ZulipBaseCommand):
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2020-07-05 14:57:52 +02:00
|
|
|
def handle(self, *args: Any, **kwargs: str) -> None:
|
|
|
|
with connection.cursor() as cursor:
|
2021-02-12 08:19:30 +01:00
|
|
|
cursor.execute(
|
|
|
|
"""
|
2020-07-05 14:57:52 +02:00
|
|
|
UPDATE zerver_message
|
|
|
|
SET search_tsvector =
|
|
|
|
to_tsvector('zulip.english_us_search', subject || rendered_content)
|
|
|
|
WHERE to_tsvector('zulip.english_us_search', subject || rendered_content) != search_tsvector
|
2021-02-12 08:19:30 +01:00
|
|
|
"""
|
|
|
|
)
|
2020-07-05 14:57:52 +02:00
|
|
|
|
|
|
|
fixed_message_count = cursor.rowcount
|
|
|
|
print(f"Fixed {fixed_message_count} messages.")
|