Port analytic_department to v8

Made the minimal changeset to make the module installable + flake8 fixing.