Esempio n. 1
0
def generate(id):
    data = parse_request(XrefSchema)
    collection = get_db_collection(id, request.authz.WRITE)
    against_ids = data.get("against_collection_ids")
    xref_collection.apply_async([collection.id],
                                kwargs={"against_collection_ids": against_ids},
                                priority=5)
    return jsonify({'status': 'accepted'}, status=202)
Esempio n. 2
0
def update_collection(collection):
    """Create or update a collection."""
    log.info("Updating: %r", collection)
    if collection.deleted_at is not None:
        index.delete_collection(collection.id)
        return

    # re-process entities
    process_entities.delay(collection_id=collection.id)

    if collection.casefile:
        xref_collection.apply_async([collection.id], priority=2)
    return index.index_collection(collection)
Esempio n. 3
0
def update_collection(collection):
    """Create or update a collection."""
    log.info("Updating: %r", collection)

    if collection.deleted_at is not None:
        index_delete(collection.id)
        return

    if collection.casefile:
        xref_collection.apply_async([collection.id], priority=2)
        # TODO: rebuild dossiers

    eq = db.session.query(Entity.id)
    eq = eq.filter(Entity.collection_id == collection.id)
    for entity in eq:
        update_entity_full.apply_async([entity.id], priority=1)

    return index_collection(collection)
Esempio n. 4
0
def update_collection(collection, roles=False):
    """Create or update a collection."""
    if collection.deleted_at is not None:
        index_delete(collection.id)
        return

    collection.updated_at = datetime.utcnow()
    db.session.add(collection)
    db.session.commit()

    log.info("Updating: %r", collection)
    index_collection(collection)
    if roles:
        update_roles(collection)

    if not collection.managed:
        xref_collection.apply_async([collection.id], priority=2)

    eq = db.session.query(Entity.id)
    eq = eq.filter(Entity.collection_id == collection.id)
    for entity in eq.all():
        update_entity_full.apply_async([entity.id], priority=2)

    flush_index()
Esempio n. 5
0
def generate_matches(collection_id, other_id):
    collection = get_db_collection(collection_id, request.authz.WRITE)
    other = get_db_collection(other_id)
    xref_collection.apply_async([collection.id, other.id], priority=6)
    return jsonify({'status': 'accepted'}, status=202)
Esempio n. 6
0
def generate_summary(collection_id):
    collection = get_db_collection(collection_id, request.authz.WRITE)
    xref_collection.apply_async([collection.id], priority=5)
    return jsonify({'status': 'accepted'}, status=202)