add time range to trending query; use time range in regression trend; properly handle end-of-results