コード例 #1
0
def index_shelflist_rows(exp):
    '''
    This is what does the work of determining the locations that need
    to be updated (based on what locations appear in the exporter
    object's record set) and stuff.
    '''
    exp.log('Info', 'Creating shelflist item manifests.')
    solr = pysolr.Solr(settings.HAYSTACK_CONNECTIONS[exp.hs_conn]['URL'])
    records = exp.get_records()
    locations = records.order_by('location__code').distinct(
        'location__code').values_list('location__code', flat=True)
    for location in locations:
        if location:
            params = {
                'q':
                '*:*',
                'fq': ['type:Item', 'location_code:{}'.format(location)],
                'fl':
                'id',
                'sort':
                'call_number_type asc, call_number_sort asc, volume_sort '
                'asc, copy_number asc',
            }
            hits = solr.search(rows=0, **params).hits
            results = solr.search(rows=hits, **params)
            data = [i['id'] for i in results]
            r = RedisObject('shelflistitem_manifest', location)
            r.set(data)
コード例 #2
0
ファイル: exporters.py プロジェクト: jthomale/catalog-api
def index_shelflist_rows(exp):
    '''
    This is what does the work of determining the locations that need
    to be updated (based on what locations appear in the exporter
    object's record set) and stuff.
    '''
    exp.log('Info', 'Creating shelflist item manifests.')
    solr = pysolr.Solr(settings.HAYSTACK_CONNECTIONS[exp.hs_conn]['URL'])
    records = exp.get_records()
    locations = records.order_by('location__code').distinct('location__code'
                        ).values_list('location__code', flat=True)
    for location in locations:
        if location:
            params = {
                'q': '*:*',
                'fq': ['type:Item', 'location_code:{}'.format(location)],
                'fl': 'id',
                'sort': 'call_number_type asc, call_number_sort asc, volume_sort '
                        'asc, copy_number asc',
            }
            hits = solr.search(rows=0, **params).hits
            results = solr.search(rows=hits, **params)
            data = [i['id'] for i in results]
            r = RedisObject('shelflistitem_manifest', location)
            r.set(data)
コード例 #3
0
ファイル: views.py プロジェクト: jthomale/catalog-api
    def paginate(self, queryset, request):
        data = super(FirstItemPerLocationList, self).paginate(queryset,
                                                              request)
        for item in data['_embedded']['items']:
            l_code = item['locationCode']
            this_id = item['id']
            item['_links']['shelflistItem'] = {
                'href': ShelflistAPIUris.get_uri(
                'shelflistitems-detail', req=request, absolute=True,
                v=self.api_version, code=l_code, id=this_id)
            }
            r = RedisObject('shelflistitem_manifest', l_code)
            item['rowNumber'] = r.get_index(this_id)

        return data
コード例 #4
0
    def get_page_data(self, queryset, request):
        data = super(FirstItemPerLocationList,
                     self).get_page_data(queryset, request)
        for item in data['_embedded']['items']:
            l_code = item['locationCode']
            this_id = item['id']
            item['_links']['shelflistItem'] = {
                'href':
                ShelflistAPIUris.get_uri('shelflistitems-detail',
                                         req=request,
                                         absolute=True,
                                         v=self.api_version,
                                         code=l_code,
                                         id=this_id)
            }
            r = RedisObject('shelflistitem_manifest', l_code)
            item['rowNumber'] = r.get_index(this_id)

        return data
コード例 #5
0
 def process_row_number(self, value, obj):
     r = RedisObject('shelflistitem_manifest', obj.location_code)
     return r.get_index(obj.id)
コード例 #6
0
ファイル: serializers.py プロジェクト: jthomale/catalog-api
 def process_row_number(self, value, obj):
     r = RedisObject('shelflistitem_manifest', obj.location_code)
     return r.get_index(obj.id)
コード例 #7
0
ファイル: tasks.py プロジェクト: unt-libraries/catalog-api
 def _get_chunk_obj(self, chunk_id):
     return RedisObject(self.redis_job_chunk_key, chunk_id)
コード例 #8
0
ファイル: tasks.py プロジェクト: unt-libraries/catalog-api
 def _get_totals_obj(self):
     return RedisObject(self.redis_job_totals_key, self.instance_pk)
コード例 #9
0
ファイル: tasks.py プロジェクト: unt-libraries/catalog-api
 def _get_reg_obj(self):
     return RedisObject(self.redis_job_reg_key, self.instance_pk)
コード例 #10
0
 def __call__(self, key):
     return RedisObject(*key.split(':'))