write_message("......Processing records #%s-%s"%(recids,recide))
recs=run_sql("SELECT id_bibrec, value FROM bib%sx, bibrec_bib%sx WHERE tag=%%s AND id_bibxxx=id and id_bibrec >=%%s and id_bibrec<=%%s"%(tag[0:2],tag[0:2]),(tag,recids,recide))
valid=HitSet(trailing_bits=1)
valid.discard(0)
forkeyintags:
newset=HitSet()
newset+=[recid[0]forrecidin(run_sql("SELECT id_bibrec FROM bib%sx, bibrec_bib%sx WHERE id_bibxxx=id AND tag=%%s AND id_bibxxx=id and id_bibrec >=%%s and id_bibrec<=%%s"%(tag[0:2],tag[0:2]),(key,recids,recide)))]
valid.intersection_update(newset)
iftags:
recs=filter(lambdax:x[0]invalid,recs)
records=records+list(recs)
write_message("Number of records found with the necessary tags: %s"%len(records))
write_message("Getting records from collections enabled for rank method.",verbose=9)
res=run_sql("SELECT collection.name FROM collection, collection_rnkMETHOD, rnkMETHOD WHERE collection.id=id_collection and id_rnkMETHOD=rnkMETHOD.id and rnkMETHOD.name=%s",(rank_method_code,))
l_of_colls=[]
forcollinres:
l_of_colls.append(coll[0])
iflen(l_of_colls)>0:
recIDs=perform_request_search(c=l_of_colls)
else:
recIDs=[]
valid=HitSet()
valid+=recIDs
returnvalid
defadd_recIDs_by_date(rank_method_code,dates=""):
"""Return recID range from records modified between DATES[0] and DATES[1].
If DATES is not set, then add records modified since the last run of
the ranking method RANK_METHOD_CODE.
"""
ifnotdates:
try:
dates=(get_lastupdated(rank_method_code),'')
exceptException,e:
dates=("0000-00-00 00:00:00",'')
ifdates[0]isNone:
dates=("0000-00-00 00:00:00",'')
query="""SELECT b.id FROM bibrec AS b WHERE b.modification_date >= %s"""
ifdates[1]:
query+=" and b.modification_date <= %s"
query+=" ORDER BY b.id ASC"""
ifdates[1]:
res=run_sql(query,(dates[0],dates[1]))
else:
res=run_sql(query,(dates[0],))
list=create_range_list(res)
ifnotlist:
write_message("No new records added since last time method was run")