Fix period and group by

Making this blow up loudly instead of fail silently. Should never happen as long as data is only imported via the API and not directly. However we should still fix it eventually.