Adds filter for labels (Fix #523)

This adds the filter for labels as requested at #523.  I've also optimized the class a little bit by consolidating the filters processed by the state into a single method and calling it from both methods building database queries.
Are you sure that this is going to work as expected?
I believe that this would also match, for example, `11` if you try to filter on `1`?