Пример #1
0
def getMetadataInfo(packageId, resourceId=None, sheetId=None):
    query = {
        "packageId" : packageId
    }

    # add additional query parameters
    if resourceId is not None:
        query['resourceId'] = resourceId
    if sheetId is not None:
        query['sheetId'] = sheetId

    sheetInfo = collections.get('resource').find_one(query)
    if sheetInfo is None:
        raise Exception('No resource found')

    query['type'] = "metadata"

    # get all distinct join values
    attrs = mongo.distinct(collections.get('spectra'), 'spectra.%s' % sheetInfo.get('joinOn'), query)
    # get total number of metadata rows or columns
    total = mongo.count(collections.get('spectra'), query)

    query = {
        "packageId" : packageId,
        "type" : "data"
    }
    query['spectra.%s' % sheetInfo.get('joinOn')] = {
        "$in" : attrs
    }

    # get the number of spectra that match to this sheet
    return {
        "joinCount": mongo.count(collections.get('spectra'), query),
        "total" : total
    }
Пример #2
0
def total(packageId, resourceId=None, sheetId=None):
    query = {
        "type" : "data",
        "packageId" : packageId
    }

    if resourceId is not None:
        query['resourceId'] = resourceId
    if sheetId is not None:
        query['sheetId'] = sheetId

    # need to support 2.8 drive cause pythons 3.0 seems to be a POS
    return {"total" : mongo.count(collections.get('spectra'), query)}