Created
July 31, 2018 19:11
-
-
Save jaredlockhart/2e04066c9f5e53a50dbb5abfb5a19d18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [94]: ExperimentEnrollment.objects.all().annotate(hour=Trunc('window_start', 'hour')).values('experiment', 'branch', 'hour').annotate(hour_enroll_sum=Sum('enroll_count'), hour_unenroll_sum=Sum('unenroll_count') | |
...: )[0] | |
{"Timestamp": 1533064257797387776, "Type": "django.db.backends", "Logger": "experimenter", "Hostname": "d8047f90780f", "EnvVersion": "2.0", "Severity": 7, "Pid": 507, "Fields": {"duration": 0.0010690689086914062, "sql": "SELECT \"experiments_experimentenrollment\".\"experiment\", \"experiments_experimentenrollment\".\"branch\", DATE_TRUNC('hour', \"experiments_experimentenrollment\".\"window_start\" AT TIME ZONE 'UTC') AS \"hour\", SUM(\"experiments_experimentenrollment\".\"enroll_count\") AS \"hour_enroll_sum\", SUM(\"experiments_experimentenrollment\".\"unenroll_count\") AS \"hour_unenroll_sum\" FROM \"experiments_experimentenrollment\" GROUP BY \"experiments_experimentenrollment\".\"experiment\", \"experiments_experimentenrollment\".\"branch\", DATE_TRUNC('hour', \"experiments_experimentenrollment\".\"window_start\" AT TIME ZONE 'UTC') LIMIT 1", "params": ["UTC", "UTC"], "message": "(0.001) SELECT \"experiments_experimentenrollment\".\"experiment\", \"experiments_experimentenrollment\".\"branch\", DATE_TRUNC('hour', \"experiments_experimentenrollment\".\"window_start\" AT TIME ZONE 'UTC') AS \"hour\", SUM(\"experiments_experimentenrollment\".\"enroll_count\") AS \"hour_enroll_sum\", SUM(\"experiments_experimentenrollment\".\"unenroll_count\") AS \"hour_unenroll_sum\" FROM \"experiments_experimentenrollment\" GROUP BY \"experiments_experimentenrollment\".\"experiment\", \"experiments_experimentenrollment\".\"branch\", DATE_TRUNC('hour', \"experiments_experimentenrollment\".\"window_start\" AT TIME ZONE 'UTC') LIMIT 1; args=('UTC', 'UTC')"}} | |
Out[94]: | |
{'experiment': 'pref-flip-activity-stream-experiment-1', | |
'branch': 'variant', | |
'hour': datetime.datetime(2018, 8, 1, 3, 0, tzinfo=<UTC>), | |
'hour_enroll_sum': 71, | |
'hour_unenroll_sum': 122} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment