Exemplo n.º 1
0
def get_number_of_reviews(recid):
    """Return number of reviews for given record.

    :param recid:

    :return: Number of reviews
    """
    from invenio.modules.comments.models import CmtRECORDCOMMENT
    if recid:
        return CmtRECORDCOMMENT.count(*[
            CmtRECORDCOMMENT.id_bibrec == recid,
            CmtRECORDCOMMENT.star_score > 0
        ])
Exemplo n.º 2
0
def reviews_nb_counts():
    """Get number of reviews for the record `recid`."""
    recid = request.view_args.get('recid')

    if recid is None:
        return
    elif recid == 0:
        return 0
    else:
        return CmtRECORDCOMMENT.count(*[
            CmtRECORDCOMMENT.id_bibrec == recid,
            CmtRECORDCOMMENT.star_score > 0,
            CmtRECORDCOMMENT.status.notin_(['dm', 'da'])
        ])
Exemplo n.º 3
0
def get_number_of_comments(recid):
    """
    Return number of comments for given record.

    :param recid:

    :return: Number of comments
    """
    from invenio.modules.comments.models import CmtRECORDCOMMENT
    if recid:
        filters = [
            CmtRECORDCOMMENT.id_bibrec == recid,
            CmtRECORDCOMMENT.star_score == 0
        ]
        return CmtRECORDCOMMENT.count(*filters)