nodes: 0, module; 1, function_definition; 2, function_name:get_queryset; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Query for the most voted messages sorting by the sum of
          voted and after by date."""; 12, assignment; 13, assignment; 14, assignment; 15, call; 16, identifier:queryset; 17, call; 18, identifier:sql; 19, comment:"""
              SELECT
                  count(sav.id)
              FROM
                  colab_superarchives_vote AS sav
              WHERE
                  colab_superarchives_message.id = sav.message_id
          """; 20, identifier:messages; 21, call; 22, attribute; 23, argument_list; 24, attribute; 25, argument_list; 26, attribute; 27, argument_list; 28, identifier:messages; 29, identifier:order_by; 30, string; 31, string; 32, call; 33, identifier:get_queryset; 34, identifier:queryset; 35, identifier:extra; 36, keyword_argument; 37, string_content:-vote_count; 38, string_content:received_time; 39, identifier:super; 40, argument_list; 41, identifier:select; 42, dictionary; 43, identifier:MostVotedManager; 44, identifier:self; 45, pair; 46, string; 47, identifier:sql; 48, string_content:vote_count
code: def get_queryset(self):
          """Query for the most voted messages sorting by the sum of
          voted and after by date."""
  
          queryset = super(MostVotedManager, self).get_queryset()
  
          sql = """
              SELECT
                  count(sav.id)
              FROM
                  colab_superarchives_vote AS sav
              WHERE
                  colab_superarchives_message.id = sav.message_id
          """
  
          messages = queryset.extra(
              select={
                  'vote_count': sql,
              }
          )
          return messages.order_by('-vote_count', 'received_time')