Only include current certificates in status count
Clean up some scopes that appeared to be named incorrectly

The expired(surveys) scope was selecting only certificates without an expiry date. It was only being used by set_expired(surveys) though so I renamed and refactored that to use a subquery instead of a select and in condition.
Merge pull request #950 from theodi/feature-more-accurate-certificate-stat

Only count current certificates
Change source questionnaire to beta state

In case the questionnaire is regenerated again it doesn't revert back to
alpha state.
Include search terms in feed link
Use the features of ransack to filter in the database

Instead of loading all the models into memory. This should make
search more performant now that we have several thousand certificates.
Ability to filter by domain or dataset documentation_url

Use domain=data.gov.uk in query string of index page
Remove debug Airbrake message

It was causing us to hit our Airbrake limit and the problem is known now.

It’s some data with urls with ‘_’ in them which are not valid URIs
Merge pull request #951 from theodi/feature-feed-filtered-by-search

Feed improvements
Also generate certificate if only draft certificates exist
Extract params checks to before_filters

The if statement was getting too unruly to be readable.
Clean up create method

By extracting all negative responses to before filter checks.
Memoizing the creation of campaign - sorry about the :nil_but_true
Pass existing dataset through params hash to method
  (I wish ruby had decorators)
It’s the certificates published state that matters
Merge pull request #952 from theodi/feature-import-draft-existing-datasets

Create certificates for datasets with only draft certificates
Filter results by certificate level
Only use values if they are not blank
Show advanced search options.

A basic form is better than magic undocumented features
Merge pull request #953 from theodi/feature-filter-by-certificate-type

Filter by certificate type and provide an advanced search form
Show request to claim certificate when not the owner.
Email should definitely be sent async

Otherwise timeouts on the smtp server can bubble up to the user.