"The repository's publication is missing" after manually stopping repository sync jobs

Ok, i think i have solved the problem.

I ran:
foreman-rake katello:regenerate_repo_metadata
This seems to have worked. It generated a lot of tasks, many of which were seemingly identical.
I think it created new metadata and re-published content views but im not sure…
Tried reading the sourcecode but found it kinda hard to trace out what was going on.