def get_recIDs_by_date(dates=""): """Returns recIDs modified between DATES[0] and DATES[1]. If DATES is not set, then returns records modified since the last run of the ranking method. """ if not dates: write_message("Using the last update time for the rank method") res = run_sql('SELECT last_updated FROM rnkMETHOD WHERE name="wrd"') if not res: return if not res[0][0]: dates = ("0000-00-00", '') else: dates = (res[0][0], '') if dates[1]: res = run_sql( 'SELECT id FROM bibrec WHERE modification_date >= %s AND modification_date <= %s ORDER BY id ASC', (dates[0], dates[1])) else: res = run_sql( 'SELECT id FROM bibrec WHERE modification_date >= %s ORDER BY id ASC', (dates[0], )) return create_range_list([row[0] for row in res])
def add_recIDs_by_date(rank_method_code, dates=None): """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. """ if not dates: dates = (get_lastupdated(rank_method_code), '') if dates[0] is None: dates = ("0000-00-00 00:00:00", '') query = """SELECT b.id FROM bibrec AS b WHERE b.modification_date >= %s""" if dates[1]: query += " and b.modification_date <= %s" query += " ORDER BY b.id ASC""" if dates[1]: res = run_sql(query, (dates[0], dates[1])) else: res = run_sql(query, (dates[0], )) alist = create_range_list([row[0] for row in res]) if not alist: write_message("No new records added since last time method was run") return alist
def get_recIDs_by_date(dates=""): """Returns recIDs modified between DATES[0] and DATES[1]. If DATES is not set, then returns records modified since the last run of the ranking method. """ if not dates: write_message("Using the last update time for the rank method") res = run_sql('SELECT last_updated FROM rnkMETHOD WHERE name="wrd"') if not res: return if not res[0][0]: dates = ("0000-00-00",'') else: dates = (res[0][0],'') if dates[1]: res = run_sql('SELECT id FROM bibrec WHERE modification_date >= %s AND modification_date <= %s ORDER BY id ASC', (dates[0], dates[1])) else: res = run_sql('SELECT id FROM bibrec WHERE modification_date >= %s ORDER BY id ASC', (dates[0],)) return create_range_list([row[0] for row in res])
def add_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. """ if not dates: try: dates = (get_lastupdated(rank_method_code), '') except Exception: dates = ("0000-00-00 00:00:00", '') if dates[0] is None: dates = ("0000-00-00 00:00:00", '') query = """SELECT b.id FROM bibrec AS b WHERE b.modification_date >= %s""" if dates[1]: query += " and b.modification_date <= %s" query += " ORDER BY b.id ASC""" if dates[1]: res = run_sql(query, (dates[0], dates[1])) else: res = run_sql(query, (dates[0], )) alist = create_range_list([row[0] for row in res]) if not alist: write_message("No new records added since last time method was run") return alist
if not dates: try: dates = (get_lastupdated(rank_method_code), '') except Exception, e: dates = ("0000-00-00 00:00:00", '') if dates[0] is None: dates = ("0000-00-00 00:00:00", '') query = """SELECT b.id FROM bibrec AS b WHERE b.modification_date >= %s""" if dates[1]: query += " and b.modification_date <= %s" query += " ORDER BY b.id ASC""" if dates[1]: res = run_sql(query, (dates[0], dates[1])) else: res = run_sql(query, (dates[0], )) alist = create_range_list([row[0] for row in res]) if not alist: write_message("No new records added since last time method was run") return alist def getName(rank_method_code, ln=CFG_SITE_LANG, type='ln'): """Returns the name of the method if it exists""" try: rnkid = run_sql("SELECT id FROM rnkMETHOD where name=%s", (rank_method_code, )) if rnkid: rnkid = str(rnkid[0][0]) res = run_sql("SELECT value FROM rnkMETHODNAME where type=%s and ln=%s and id_rnkMETHOD=%s", (type, ln, rnkid)) if not res: res = run_sql("SELECT value FROM rnkMETHODNAME WHERE ln=%s and id_rnkMETHOD=%s and type=%s", (CFG_SITE_LANG, rnkid, type)) if not res: