-
Notifications
You must be signed in to change notification settings - Fork 0
/
09-aybee.sql
114 lines (111 loc) · 6.37 KB
/
09-aybee.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
do $$
declare
experiment aybee_dashboard.experiment;
begin
insert into aybee_dashboard.organization( id, name ) values ('979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'aybee');
insert into aybee_dashboard.person( id, organization_id, name ) values (
'298990a4-6f55-11e8-a172-db9b0a334b77',
'979fc2bc-6f54-11e8-a172-7fb168c1de7f',
'aybee'
);
insert into aybee_dashboard.organization( id, name ) values ('979fc2bc-6f54-11e8-a172-222222222222', 'aybee2');
insert into aybee_dashboard.person( id, organization_id, name ) values (
'298990a4-6f55-11e8-a172-222222222222',
'979fc2bc-6f54-11e8-a172-222222222222',
'aybee2'
);
insert into aybee_private.account(person_id, email, password_hash)
values('298990a4-6f55-11e8-a172-db9b0a334b77', 'a@b.com', crypt('senha', gen_salt('bf')));
insert into aybee_dashboard.platform( id, organization_id, name )
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'iOS');
insert into aybee_dashboard.identifier( id, organization_id, name )
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'accountId');
insert into aybee_dashboard.track( id, organization_id, platform_id, identifier_id, name )
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'test 001');
insert into aybee_dashboard.experiment( id, organization_id, track_id, name )
values('6f5794f2-77fa-11e8-af51-33e8d37243c0', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'exp 001');
insert into aybee_dashboard.variant( id, organization_id, experiment_id, name, percent )
values('b824cff8-77fd-11e8-b5d6-2f651c118cf6', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '6f5794f2-77fa-11e8-af51-33e8d37243c0', 'A', .01);
insert into aybee_dashboard.token(id, organization_id, platform_id)
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f');
assert (select count(*) from aybee_dashboard.variant_track) = 1;
assert (select percent_range from aybee_dashboard.variant_track) = '[0,0.01)'::numrange;
insert into aybee_dashboard.variant( id, organization_id, experiment_id, name, percent )
values('b824cff8-77fd-11e8-b5d6-666666666666', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '6f5794f2-77fa-11e8-af51-33e8d37243c0', 'B', .1);
assert (select percent_range from aybee_dashboard.variant_track order by 1 desc limit 1) = '[0.01,0.11)'::numrange;
update aybee_dashboard.variant set percent = .02 where id = 'b824cff8-77fd-11e8-b5d6-2f651c118cf6';
assert (select percent_range from aybee_dashboard.variant_track order by 1 desc limit 1) = '[0.11,0.12)'::numrange;
update aybee_dashboard.variant set percent = .01 where id = 'b824cff8-77fd-11e8-b5d6-666666666666';
assert (select percent_range from aybee_dashboard.variant_track where variant_id = 'b824cff8-77fd-11e8-b5d6-666666666666' limit 1) = '[0.01,0.02)'::numrange;
insert into aybee_dashboard.variant( id, organization_id, experiment_id, name, percent )
values('b824cff8-77fd-11e8-b5d6-888888888888', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '6f5794f2-77fa-11e8-af51-33e8d37243c0', 'C', .5);
assert (select count(*) from aybee_dashboard.variant_track where variant_id = 'b824cff8-77fd-11e8-b5d6-888888888888') = 2;
assert (
select
percent_range
from
aybee_dashboard.variant_track
where
variant_id = 'b824cff8-77fd-11e8-b5d6-888888888888'
order by 1
limit 1
offset 0
) = '[0.02,0.11)'::numrange;
assert (
select
percent_range
from
aybee_dashboard.variant_track
where
variant_id = 'b824cff8-77fd-11e8-b5d6-888888888888'
order by 1
limit 1
offset 1
) = '[0.12,0.53)'::numrange;
select * into experiment from aybee_dashboard.experiment where id = '6f5794f2-77fa-11e8-af51-33e8d37243c0';
perform aybee_dashboard.segregate_experiment(experiment);
assert (
select
count(*)
from
aybee_dashboard.variant_track
where
track_id = '979fc2bc-6f54-11e8-a172-7fb168c1de7f'
) = 0;
assert (
select
count(*)
from
aybee_dashboard.variant_track
) = 5;
update aybee_dashboard.experiment set track_id = '979fc2bc-6f54-11e8-a172-7fb168c1de7f';
assert (
select
count(*)
from
aybee_dashboard.variant_track
where
track_id = '979fc2bc-6f54-11e8-a172-7fb168c1de7f'
) = 3;
assert (
select
count(*)
from
aybee_dashboard.variant_track
) = 3;
insert into aybee_dashboard.variable(id, organization_id, platform_id, name)
values('979fc2bc-6f54-11e8-a172-111111111111', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'bla');
insert into aybee_dashboard.variable_variant(organization_id, variable_id, variant_id, value)
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', '979fc2bc-6f54-11e8-a172-111111111111', 'b824cff8-77fd-11e8-b5d6-2f651c118cf6', '{"bla":"ble"}');
insert into aybee_dashboard.metric_config(token_id)
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f');
update aybee_dashboard.metric_config
set
metric_storage = 'postgresql',
conf = '{"user": "aybee_metric_writer", "host": "localhost", "database": "aybee", "password": "123"}';
insert into aybee_dashboard.metric_type(organization_id, name)
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'productVisualized');
insert into aybee_dashboard.metric_type(organization_id, name)
values('979fc2bc-6f54-11e8-a172-7fb168c1de7f', 'listProduct');
end;
$$