Get some high-level data on our sends table.
select
min(sent_on) as first_date,
max(sent_on) as latest_date,
count(*) as total_records,
count(distinct template) as unique_templates,
count(distinct sent_on) as unique_dates
from| id | edge_top | edge_right | edge_bottom | edge_left | orientation | row | col | |
|---|---|---|---|---|---|---|---|---|
| 2917 | tab-7750469 | tab-17732443 | tab-4722623 | tab-8858929 | ||||
| 5881 | tab-38067713 | blank-29069783 | blank-37044419 | tab-16331537 | ||||
| 6199 | tab-36443921 | tab-30988801 | tab-21950659 | tab-37745711 | ||||
| 4217 | tab-11213003 | tab-1463299 | blank-8505689 | tab-27330377 | ||||
| 1019 | blank-4370491 | tab-7873813 | tab-3761129 | blank-8069461 | ||||
| 6337 | tab-46570613 | tab-34099397 | blank-37077787 | blank-3035423 | ||||
| 3517 | blank-8901527 | blank-7867529 | tab-23279023 | tab-18671753 | ||||
| 7069 | tab-34433099 | blank-39027949 | tab-43976249 | blank-6029857 | ||||
| 7691 | blank-26664697 | tab-51675829 | tab-60966557 | tab-2407283 |
| -- let's check what our table looks like | |
| -- without bringing in everything | |
| select * from email.sends limit 10; | |
| select * from email.opens limit 10; | |
| -- how many records are in the table? | |
| select count(*) | |
| from email.sends | |
| limit 10; |
Get some high-level data on our sends table.
select
min(sent_on) as first_date,
max(sent_on) as latest_date,
count(*) as total_records,
count(distinct template) as unique_templates,
count(distinct sent_on) as unique_dates
from| with | |
| email_data as ( | |
| select | |
| s.id as send_id, | |
| s.template, | |
| s.sent_on, | |
| o.opened_on, | |
| case | |
| when opened_on is null then false |
| # install: | |
| # pip3 install python-gnupg | |
| # note - gpg needs to be installed first: | |
| # brew install gpg | |
| # apt install gpg | |
| # you may need to also: | |
| # export GPG_TTY=$(tty) |
| drop table if exists seq_test; | |
| create table seq_test as | |
| with | |
| dates as ( | |
| select | |
| 0 as id, | |
| generate_series( | |
| '2017-01-01'::date, |
| processing split transactions | |
| who | total | each | what | |
| tuck | 130 | 14.44 | Groceries | |
| tuck | 11 | 1.22 | Uber back from groceries | |
| sara | 47 | 7.83 | Dommy doms | |
| tuck | 18 | 3.6 | Lyft to smellrose | |
| sara | 7 | 2.33 | Uber | |
| tuck | 18 | 3.6 | Lyft from santas | |
| tuck | 70 | 10.0 | Lunch |
| import logging | |
| log = logging.getLogger('my-app.aux') | |
| def log_this(msg): | |
| if isinstance(msg, int): | |
| log.debug('{} is an int!'.format(msg)) | |
| return None |
| from __future__ import division | |
| from collections import Counter | |
| import itertools | |
| import six | |
| n_dice = 6 | |
| n_sides_per_die = 6 | |
| options = range(1, n_sides_per_die+1) |