web_ui: make the backlog queries compatible with MySQL

The issue is that the databases are all a bit picky about the column
type in a cast.  MySQL wants `signed`, PostgreSQL and SQLite prefer
`int` or `integer`.  As a result, we have to customize the query based
on the database being used.  Trac has a `cast()` method on the `db`
object, so let's use it to get the query into the right form.
prep for 0.3.1
open for development