def handle(self, *args, **options): analytics.init_analytics() count = 0 users = User.objects.all().order_by("id") total = users.count() for user in users: # update their orgs users = (user,) orgs = Org.objects.filter( Q(administrators__in=users) | Q(editors__in=users) | Q(viewers__in=users), is_active=True ) analytics.set_orgs(user.email, orgs) time.sleep(0.1) count += 1 if count % 1000 == 0: print(f"Updated {count} of {total} users") print(f"Updated {count} users.")
def handle(self, *args, **options): analytics.init_analytics() count = 0 users = User.objects.all().order_by("id") total = users.count() for user in users: # update their orgs users = (user, ) orgs = Org.objects.filter(Q(administrators__in=users) | Q(editors__in=users) | Q(viewers__in=users), is_active=True) analytics.set_orgs(user.email, orgs) time.sleep(.1) count += 1 if count % 1000 == 0: print(f"Updated {count} of {total} users") print(f"Updated {count} users.")
def handle(self, *args, **options): analytics.init_analytics() count = 0 consented = 0 # now all users users = User.objects.all().order_by("id") total = users.count() for user in users: # update their policy consent if Policy.get_policies_needing_consent(user): analytics.change_consent(user.email, False) else: consented += 1 analytics.change_consent(user.email, True) time.sleep(.1) count += 1 if count % 1000 == 0: print(f"Updated {count} of {total} users") print(f"Updated {count} users ({consented} consented).")
def configure_workers(sender=None, **kwargs): init_analytics() # pragma: needs cover
url(r"^jsi18n/$", JavaScriptCatalog.as_view(), js_info_dict, name="django.views.i18n.javascript_catalog"), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # import any additional urls for app in settings.APP_URLS: # pragma: needs cover importlib.import_module(app) # initialize our analytics (the signal below will initialize each worker) init_analytics() @worker_process_init.connect def configure_workers(sender=None, **kwargs): init_analytics() # pragma: needs cover def track_user(self): # pragma: no cover """ Should the current user be tracked """ # don't track unless we are on production if not settings.IS_PROD: return False
url(r"^users/", include("smartmin.users.urls")), url(r"^imports/", include("smartmin.csv_imports.urls")), url(r"^assets/", include("temba.assets.urls")), url(r"^jsi18n/$", JavaScriptCatalog.as_view(), js_info_dict, name="django.views.i18n.javascript_catalog"), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # import any additional urls for app in settings.APP_URLS: # pragma: needs cover importlib.import_module(app) # initialize our analytics (the signal below will initialize each worker) init_analytics() @worker_process_init.connect def configure_workers(sender=None, **kwargs): init_analytics() # pragma: needs cover def track_user(self): # pragma: no cover """ Should the current user be tracked """ # don't track unless we are on production if not settings.IS_PROD: return False