Is anyone aware of an efficient way to get the id of the most recently finished build - without regard to build type - via REST? I have an external script that does incremental backups of new artifacts and build logs, and one of the things it does when it starts is capture the lowest-numbered build currently running; at the end of a successful incremental backup, the value captured at the start of the run is saved, so it can be used as a starting point for looking for new artifacts and build logs during the next run.
This works well when there are actually builds running (i.e. most of the time). However, there are occasionally times when there are no builds running; at those times, the logical thing to do would be to grab the ID of the last finished build when the backup starts, and save that at the end of the backup run. But I can't find a way to do this efficiently via the REST API. I've tried a few different approaches, but they either run slowly (e.g. retrieving the list of build types - hundreds of them, in this case - then iterating over them, and getting the last build from each) or they cause TeamCity to grind to a halt with OutOfMemory errors (e.g. app/rest/builds/?count=1).