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(Numeric.ones(cfg_max_recID+1))
forkeyintags:
newset=HitSet()
newset.addlist(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.intersect(newset)
iftags:
recs=filter(lambdax:valid.contains(x[0]),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.")
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.addlist(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",'')
query="""SELECT b.id FROM bibrec AS b WHERE b.modification_date >= '%s'"""%dates[0]
ifdates[1]:
query+="and b.modification_date <= '%s'"%dates[1]
query+="ORDER BY b.id ASC"""
res=run_sql(query)
list=create_range_list(res)
ifnotlist:
ifoptions["verbose"]:
write_message("No new records added since last time method was run")