Remove some duplicate code in analytics.views
Fix cs in analysis python files