Пример #1
0
def get_no_updated_keyword_frequency_iter():
    """

    :return: Iterable of not updated keyword frequencies.
    """
    collection = yield db.get_keyword_frequency_collection()
    defer.returnValue(QueryIterator(collection.find({'updated': False}, cursor=True)))
Пример #2
0
def get_keyword_frequency(keyword):
    """

    :param keyword:
    :return: One keyword frequency document.
    """
    collection = yield db.get_keyword_frequency_collection()
    return_value = yield collection.find_one({'keyword': keyword})
    defer.returnValue(return_value)
Пример #3
0
def delete_keyword_frequency(_id):
    """
    Remove keyword frequency document.

    :param _id: Mongo document identifier.
    :return:
    """
    collection = yield db.get_keyword_frequency_collection()
    return_value = yield collection.delete_many({'_id': _id})
    defer.returnValue(return_value)
Пример #4
0
def set_keyword_frequency_updated_flag(updated=False):
    """
    Set/update the 'updated' flag in keyword frequency document.

    :param updated: Flag value (True/False)
    :return:
    """
    collection = yield db.get_keyword_frequency_collection()
    return_value = yield collection.update_many({}, {"$set": {"updated": updated}})
    defer.returnValue(return_value)
Пример #5
0
def update_keyword_frequency(keyword, frequency, updated=True):
    """
    Create or update keyword frequency.

    :param keyword:
    :param frequency:
    :param updated:
    :return:
    """
    collection = yield db.get_keyword_frequency_collection()
    return_value = yield collection.replace_one({
        'keyword': keyword
        }, {
        'keyword': keyword,
        'frequency': frequency,
        'updated': updated
        }, upsert=True)
    defer.returnValue(return_value)