Beispiel #1
0
 def get( repo, org, cid, eid, role, sha1 ):
     id = make_object_id(File.model, repo, org, cid, eid, role, sha1)
     raw = elasticsearch.get(HOST, index=settings.DOCUMENT_INDEX, model=File.model, id=id)
     status = raw['status']
     response = json.loads(raw['response'])
     if (status == 200) and (response['found'] or response['exists']):
         return build_object(File(), id, response['_source'])
     return None
Beispiel #2
0
 def get(repo, org, cid, eid, role, sha1):
     id = make_object_id(File.model, repo, org, cid, eid, role, sha1)
     raw = elasticsearch.get(HOST,
                             index=settings.DOCUMENT_INDEX,
                             model=File.model,
                             id=id)
     status = raw['status']
     response = json.loads(raw['response'])
     if (status == 200) and (response['found'] or response['exists']):
         return build_object(File(), id, response['_source'])
     return None
Beispiel #3
0
def facets_list():
    """Returns a list of facets in alphabetical order, with URLs
    """
    key = "facets:list"
    cached = cache.get(key)
    if not cached:
        facets_list = []
        for name in elasticsearch.list_facets():
            raw = elasticsearch.get(
                settings.ELASTICSEARCH_HOST_PORT, index=settings.METADATA_INDEX, model="facet", id=name
            )
            f = json.loads(raw["response"])["_source"]
            f["name"] = name
            f["url"] = reverse("ui-browse-facet", args=[name])
            facets_list.append(f)
        cached = facets_list
        cache.set(key, cached, CACHE_TIMEOUT)
    return cached
Beispiel #4
0
def facets_list():
    """Returns a list of facets in alphabetical order, with URLs
    """
    key = 'facets:list'
    cached = cache.get(key)
    if not cached:
        facets_list = []
        for name in elasticsearch.list_facets():
            raw = elasticsearch.get(settings.ELASTICSEARCH_HOST_PORT,
                                    index=settings.METADATA_INDEX,
                                    model='facet',
                                    id=name)
            f = json.loads(raw['response'])['_source']
            f['name'] = name
            f['url'] = reverse('ui-browse-facet', args=[name])
            facets_list.append(f)
        cached = facets_list
        cache.set(key, cached, CACHE_TIMEOUT)
    return cached