Example #1
0
def view(collection_id):
    """
    ---
    get:
      summary: Get a collection
      description: Return the collection with id `collection_id`
      parameters:
      - description: The collection ID.
        in: path
        name: collection_id
        required: true
        schema:
          minimum: 1
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionFull'
      tags:
      - Collection
    """
    data = get_index_collection(collection_id)
    cobj = get_db_collection(collection_id)
    if get_flag("refresh", False):
        update_collection_stats(collection_id, ["schema"])
    data.update({
        "statistics": get_collection_stats(cobj.id),
        "status": get_status(cobj),
        "shallow": False,
    })
    return CollectionSerializer.jsonify(data)
Example #2
0
def get_deep_collection(collection):
    mappings = Mapping.by_collection(collection.id).count()
    entitysets = EntitySet.type_counts(collection_id=collection.id)
    return {
        "statistics": index.get_collection_stats(collection.id),
        "counts": {"mappings": mappings, "entitysets": entitysets},
        "status": get_status(collection),
        "shallow": False,
    }
Example #3
0
def statistics(collection_id):
    """
    ---
    get:
      summary: Get a summary of collection contents
      description: >
        Get a listing of the most common entity types and attributes in the
        given collection. The result is cached and can be somewhat out of
        sync with the real numbers.
      parameters:
      - description: The collection ID.
        in: path
        name: collection_id
        required: true
        schema:
          minimum: 1
          type: integer
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  schema:
                    type: object
                  names:
                    type: object
                  addresses:
                    type: object
                  countries:
                    type: object
                  languages:
                    type: object
                  phones:
                    type: object
                  emails:
                    type: object
                  ibans:
                    type: object
      tags:
      - Collection
    """
    collection = get_db_collection(collection_id, request.authz.READ)
    return jsonify(get_collection_stats(collection.id))
Example #4
0
def view(id):
    collection = get_collection(id)
    data, _ = CollectionSchema().dump(collection)
    data.update(get_collection_stats(collection.id))
    return jsonify(data)