Beispiel #1
0
    def __create_batched_query_string(self):
        batched_queries = []

        for idx, query in enumerate(self.queries):
            [metric, _separator, slug] = query[0].partition('/')
            if metric in QUERY_MAPPING:
                batched_queries.append(get_gql_query(idx, query[0],
                                                     **query[1]))
            else:
                if slug != '':
                    batched_queries.append(
                        san.sanbase_graphql.get_metric(idx, metric, slug,
                                                       **query[1]))
                else:
                    raise SanError('Invalid metric!')
        self.__batch_gql_queries(batched_queries)
        return self.__batch_gql_queries(batched_queries)
Beispiel #2
0
def get(dataset, **kwargs):
    query, slug = parse_dataset(dataset)
    if query in DEPRECATED_QUERIES:
        print(
            '**NOTICE**\n{} will be deprecated in version 0.9.0, please use {} instead'
            .format(query, DEPRECATED_QUERIES[query]))
    if query in CUSTOM_QUERIES:
        return getattr(san.sanbase_graphql, query)(0, slug, **kwargs)
    if query in QUERY_MAPPING.keys():
        gql_query = "{" + get_gql_query(0, dataset, **kwargs) + "}"
    else:
        if slug != '':
            gql_query = "{" + \
                san.sanbase_graphql.get_metric(0, query, slug, **kwargs) + "}"
        else:
            raise SanError('Invalid metric!')
    res = execute_gql(gql_query)

    return transform_query_result(0, query, res)