Beispiel #1
0
def _get_comment_sorter(link_id, sort):
    """Retrieve cached sort values for all comments on a post.

    Arguments:

    * link_id -- id of the Link containing the comments.
    * sort -- a string indicating the attribute on the comments to use for
      generating sort values.

    Returns a dictionary from cid to a numeric sort value.
    """
    from r2.models import CommentSortsCache
    from r2.lib.db.tdb_cassandra import NotFound

    key = sort_comments_key(link_id, sort)
    try:
        sorter = CommentSortsCache._byID(key)._values()
    except NotFound:
        return {}

    # we store these id36ed, but there are still bits of the code that
    # want to deal in integer IDs
    sorter = dict((int(c_id, 36), val)
                  for (c_id, val) in sorter.iteritems())
    return sorter
Beispiel #2
0
def _get_comment_sorter(link_id, sort):
    from r2.models import CommentSortsCache
    from r2.lib.db.tdb_cassandra import NotFound

    key = sort_comments_key(link_id, sort)
    try:
        sorter = CommentSortsCache._byID(key)._values()
    except NotFound:
        return {}

    # we store these id36ed, but there are still bits of the code that
    # want to deal in integer IDs
    sorter = dict((int(c_id, 36), val) for (c_id, val) in sorter.iteritems())
    return sorter
Beispiel #3
0
def _get_comment_sorter(link_id, sort):
    from r2.models import CommentSortsCache
    from r2.lib.db.tdb_cassandra import NotFound

    key = sort_comments_key(link_id, sort)
    try:
        sorter = CommentSortsCache._byID(key)._values()
    except NotFound:
        return {}

    # we store these id36ed, but there are still bits of the code that
    # want to deal in integer IDs
    sorter = dict((int(c_id, 36), val) for (c_id, val) in sorter.iteritems())
    return sorter
Beispiel #4
0
def _get_comment_sorter(link_id, sort):
    """Retrieve cached sort values for all comments on a post.

    Arguments:

    * link_id -- id of the Link containing the comments.
    * sort -- a string indicating the attribute on the comments to use for
      generating sort values.

    Returns a dictionary from cid to a numeric sort value.
    """
    from r2.models import CommentSortsCache
    from r2.lib.db.tdb_cassandra import NotFound

    key = sort_comments_key(link_id, sort)
    try:
        sorter = CommentSortsCache._byID(key)._values()
    except NotFound:
        return {}

    # we store these id36ed, but there are still bits of the code that
    # want to deal in integer IDs
    sorter = dict((int(c_id, 36), val) for (c_id, val) in sorter.iteritems())
    return sorter