I've put together a basic method of querying the long term database that can be used as a starting point for constructing your own queries