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 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
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