The event naturally fires every time book(s) are added and selects those books exclusively. Does not make sense for it to select books that were added an hour ago, at which time the event fired for these books.
Seems like you want to do is more suited for a timer event that executes a chain periodically at a configurable time intervals.
Whichever way you choose to go, here is a python template that should work with the "Search using template" action, it will select books added in the last hour, you can edit the code (the part highlighted in red), to your liking.
Code:
python:
def evaluate(book, context):
from calibre.utils.date import now
book_ids = ''
db = context.db
current = now()
for book_id in db.data.search_getting_ids('date:today', ''):
dt = db.new_api.field_for('timestamp',book_id)
delta = current - dt
if delta.total_seconds() < 60 * 60:
book_ids += f'{book_id},'
return book_ids.strip(',')
Now, in the settings of the action make sure to do the following:
- Tick the option "search result is book ids"
- Tick the checkbox "Select books"