mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			756 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			756 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from typing import Any
 | 
						|
 | 
						|
from django.db import connection
 | 
						|
from typing_extensions import override
 | 
						|
 | 
						|
from zerver.lib.management import ZulipBaseCommand
 | 
						|
 | 
						|
 | 
						|
class Command(ZulipBaseCommand):
 | 
						|
    @override
 | 
						|
    def handle(self, *args: Any, **kwargs: str) -> None:
 | 
						|
        with connection.cursor() as cursor:
 | 
						|
            cursor.execute(
 | 
						|
                """
 | 
						|
                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
 | 
						|
            """
 | 
						|
            )
 | 
						|
 | 
						|
            fixed_message_count = cursor.rowcount
 | 
						|
            print(f"Fixed {fixed_message_count} messages.")
 |