Function which returns number of inserts which took place in given month (splited into days)
@param oai_src_id: harvesting source identifier
@return: Dictionary of harvesting statistics - keys describe days. values - numbers of inserted recordds
"""
sql_column="date_harvested"
ifmethod=="inserted":
sql_column="date_inserted"
query="SELECT DAY("+sql_column+"), COUNT(*) FROM oaiHARVESTLOG WHERE id_oaiHARVEST = %s AND MONTH("+sql_column+") = %s AND YEAR("+sql_column+")= %s GROUP BY DAY("+sql_column+")"
Function which returns number of inserts which took place in given day
@param oai_src_id: harvesting source identifier
@return: Number of inserts during the given day
"""
sql_column="date_harvested"
ifmethod=="inserted":
sql_column="date_inserted"
query="SELECT COUNT(*) FROM oaiHARVESTLOG WHERE id_oaiHARVEST = %s AND MONTH("+sql_column+") = %s AND YEAR("+sql_column+")= %s AND DAY("+sql_column+") = %s"
filterSql=" and oai_id like '%%%s%%' "%(filter_key,)
query="SELECT oai_id, changeset_date, changeset_id FROM bibHOLDINGPEN WHERE changeset_date > '%i-%i-%i 00:00:00' and changeset_date <= '%i-%i-%i 23:59:59' %s ORDER BY changeset_date LIMIT %i, %i"%(year,month,day,year,month,day,filterSql,start,limit)
filterSql=" and oai_id like '%%%s%%' "%(filter_key,)
query="SELECT count(*) FROM bibHOLDINGPEN WHERE year(changeset_date) = '%i' and month(changeset_date) = '%i' and day(changeset_date) = '%i' %s"%(year,month,day,filterSql)
query_results=run_sql(query)
returnint(query_results[0][0])
defget_holdingpen_month(year,month,filter_key):
"""
Returning the statistics about the entries form a particular month
"""
filterSql=""
iffilter_key!="":
filterSql=" and oai_id like '%%%s%%' "%(filter_key,)
query="select day(changeset_date), count(*) from bibHOLDINGPEN where year(changeset_date) = '%i' and month(changeset_date) = '%i' %s group by day(changeset_date)"%(year,month,filterSql)
returnrun_sql(query)
defget_holdingpen_year(year,filter_key):
"""
Returning the statistics about the entries from a particular year
"""
filterSql=""
iffilter_key!="":
filterSql=" and oai_id like '%%%s%%' "%(filter_key,)
query="select month(changeset_date), count(*) from bibHOLDINGPEN where year(changeset_date) = '%i' %s group by month(changeset_date)"%(year,filterSql)
returnrun_sql(query)
defget_holdingpen_years(filter_key):
"""
Returning the particular years of records present in the holding pen
"""
filterSql=""
iffilter_key!="":
filterSql=" where oai_id like '%%%s%%' "%(filter_key,)
query="select year(changeset_date), count(*) changeset_date from bibHOLDINGPEN %s group by year(changeset_date)"%(filterSql,)
results=run_sql(query)
returnresults
defget_holdingpen_entry_details(hpupdate_id):
"""
Returning the detials of the Holding Pen entry, the result of this function is a tuple:
(oai_id, record_id, date_inserted, content)
"""
query="SELECT oai_id, id_bibrec, changeset_date, changeset_xml FROM bibHOLDINGPEN WHERE changeset_id=%s"