Diversify persistent scale fixtures
This commit is contained in:
parent
4490280e0e
commit
227c0bdc0c
|
|
@ -311,33 +311,68 @@ defmodule Mix.Tasks.Wnh.ScaleFixtures do
|
|||
'Scale help request ' || value,
|
||||
'Persistent synthetic local scale request used to test viewport discovery and UI.',
|
||||
'Synthetic data only; no real-world action is requested.',
|
||||
'{"scale_fixture":true}'::jsonb,
|
||||
city.name || ' scale area',
|
||||
CASE WHEN value % 97 = 0 THEN NULL ELSE ST_SetSRID(
|
||||
'{"scale_fixture":true,"scale_fixture_version":3}'::jsonb,
|
||||
city.name || ' synthetic zone ' ||
|
||||
((variation.category_key + variation.time_key) % 100 + 1),
|
||||
CASE WHEN variation.visibility_key % 97 = 0 THEN NULL ELSE ST_SetSRID(
|
||||
ST_MakePoint(
|
||||
city.longitude + (((value * 97) % 1001) - 500) / 100000.0,
|
||||
city.latitude + (((value * 193) % 1001) - 500) / 100000.0
|
||||
city.longitude +
|
||||
((variation.longitude_key % 4001) - 2000) / 1000.0,
|
||||
city.latitude +
|
||||
((variation.latitude_key % 4003) - 2001) / 1000.0
|
||||
),
|
||||
4326
|
||||
) END,
|
||||
CASE WHEN value % 10 < 8 THEN 'open'
|
||||
WHEN value % 10 = 8 THEN 'completed'
|
||||
CASE WHEN variation.status_key % 10 < 8 THEN 'open'
|
||||
WHEN variation.status_key % 10 = 8 THEN 'completed'
|
||||
ELSE 'cancelled' END,
|
||||
CASE value % 3 WHEN 0 THEN 'now' WHEN 1 THEN 'today' ELSE 'scheduled' END,
|
||||
CASE WHEN value % 97 = 0 THEN 'hidden'
|
||||
WHEN value % 4 = 0 THEN 'exact_public'
|
||||
WHEN value % 4 = 1 THEN 'exact_for_active_match'
|
||||
CASE (variation.status_key / 10) % 3
|
||||
WHEN 0 THEN 'now'
|
||||
WHEN 1 THEN 'today'
|
||||
ELSE 'scheduled'
|
||||
END,
|
||||
CASE WHEN variation.visibility_key % 97 = 0 THEN 'hidden'
|
||||
WHEN (variation.visibility_key / 97) % 4 = 0 THEN 'exact_public'
|
||||
WHEN (variation.visibility_key / 97) % 4 = 1
|
||||
THEN 'exact_for_active_match'
|
||||
ELSE 'approximate_public' END,
|
||||
CASE WHEN value % 97 = 0 OR value % 4 = 0 THEN NULL
|
||||
WHEN value % 3 = 0 THEN 500
|
||||
WHEN value % 3 = 1 THEN 1000
|
||||
CASE WHEN variation.visibility_key % 97 = 0
|
||||
OR (variation.visibility_key / 97) % 4 = 0 THEN NULL
|
||||
WHEN (variation.visibility_key / 388) % 3 = 0 THEN 500
|
||||
WHEN (variation.visibility_key / 388) % 3 = 1 THEN 1000
|
||||
ELSE 2000 END,
|
||||
date_trunc('second', now()) + ((value % 30) + 1) * interval '1 day',
|
||||
md5('wnh-scale-user-' || ((value % $2) + 1))::uuid,
|
||||
(($3::text[])[((value - 1) % cardinality($3::text[])) + 1])::uuid,
|
||||
date_trunc('second', now()) +
|
||||
((variation.time_key % 30) + 1) * interval '1 day',
|
||||
md5(
|
||||
'wnh-scale-user-' ||
|
||||
((variation.longitude_key * 37 + variation.latitude_key) % $2 + 1)
|
||||
)::uuid,
|
||||
(($3::text[])[
|
||||
(variation.category_key % cardinality($3::text[])) + 1
|
||||
])::uuid,
|
||||
date_trunc('second', now()) - value * interval '1 second',
|
||||
date_trunc('second', now()) - value * interval '1 second'
|
||||
FROM generate_series(1, $1) AS value
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT
|
||||
((value - 1) % 20)::integer AS city_index,
|
||||
md5('wnh-scale-request-v3-' || value) AS fixture_hash
|
||||
) AS fixture
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT
|
||||
('x' || substr(fixture.fixture_hash, 1, 8))::bit(32)::bigint
|
||||
AS longitude_key,
|
||||
('x' || substr(fixture.fixture_hash, 9, 8))::bit(32)::bigint
|
||||
AS latitude_key,
|
||||
('x' || substr(fixture.fixture_hash, 17, 4))::bit(16)::bigint
|
||||
AS status_key,
|
||||
('x' || substr(fixture.fixture_hash, 21, 4))::bit(16)::bigint
|
||||
AS visibility_key,
|
||||
('x' || substr(fixture.fixture_hash, 25, 4))::bit(16)::bigint
|
||||
AS time_key,
|
||||
('x' || substr(fixture.fixture_hash, 29, 4))::bit(16)::bigint
|
||||
AS category_key
|
||||
) AS variation
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT *
|
||||
FROM (
|
||||
|
|
@ -363,9 +398,22 @@ defmodule Mix.Tasks.Wnh.ScaleFixtures do
|
|||
(18, 'Sydney', 151.2093, -33.8688),
|
||||
(19, 'Auckland', 174.7633, -36.8485)
|
||||
) AS cities(index, name, longitude, latitude)
|
||||
WHERE cities.index = value % 20
|
||||
WHERE cities.index = fixture.city_index
|
||||
) AS city
|
||||
ON CONFLICT (id) DO NOTHING
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
structured_data = EXCLUDED.structured_data,
|
||||
location_label = EXCLUDED.location_label,
|
||||
location = EXCLUDED.location,
|
||||
status = EXCLUDED.status,
|
||||
urgency = EXCLUDED.urgency,
|
||||
location_visibility = EXCLUDED.location_visibility,
|
||||
location_radius_meters = EXCLUDED.location_radius_meters,
|
||||
expires_at = EXCLUDED.expires_at,
|
||||
requester_id = EXCLUDED.requester_id,
|
||||
category_id = EXCLUDED.category_id,
|
||||
updated_at = EXCLUDED.updated_at
|
||||
WHERE help_requests.structured_data @> '{"scale_fixture":true}'::jsonb
|
||||
AND help_requests.structured_data ->> 'scale_fixture_version' IS DISTINCT FROM '3'
|
||||
""",
|
||||
[rows, @synthetic_users, category_ids],
|
||||
timeout: :infinity,
|
||||
|
|
@ -385,27 +433,60 @@ defmodule Mix.Tasks.Wnh.ScaleFixtures do
|
|||
md5('wnh-scale-activity-v1-' || value)::uuid,
|
||||
'Scale community activity ' || value,
|
||||
'Persistent synthetic local scale activity used to test viewport discovery and UI.',
|
||||
'{"scale_fixture":true}'::jsonb,
|
||||
city.name || ' public meeting area',
|
||||
'{"scale_fixture":true,"scale_fixture_version":3}'::jsonb,
|
||||
city.name || ' synthetic zone ' ||
|
||||
((variation.category_key + variation.time_key) % 100 + 1),
|
||||
ST_SetSRID(
|
||||
ST_MakePoint(
|
||||
city.longitude + (((value * 89) % 1001) - 500) / 100000.0,
|
||||
city.latitude + (((value * 181) % 1001) - 500) / 100000.0
|
||||
city.longitude +
|
||||
((variation.longitude_key % 4001) - 2000) / 1000.0,
|
||||
city.latitude +
|
||||
((variation.latitude_key % 4003) - 2001) / 1000.0
|
||||
),
|
||||
4326
|
||||
),
|
||||
CASE WHEN value % 97 = 0 THEN 'hidden' ELSE 'approximate_public' END,
|
||||
CASE WHEN value % 10 < 8 THEN 'open'
|
||||
WHEN value % 10 = 8 THEN 'completed'
|
||||
CASE WHEN variation.visibility_key % 97 = 0
|
||||
THEN 'hidden'
|
||||
ELSE 'approximate_public'
|
||||
END,
|
||||
CASE WHEN variation.status_key % 10 < 8 THEN 'open'
|
||||
WHEN variation.status_key % 10 = 8 THEN 'completed'
|
||||
ELSE 'cancelled' END,
|
||||
date_trunc('second', now()) + ((value % 60) + 2) * interval '1 day',
|
||||
date_trunc('second', now()) + ((value % 60) + 1) * interval '1 day',
|
||||
2 + (value % 19),
|
||||
md5('wnh-scale-user-' || ((value % $2) + 1))::uuid,
|
||||
(($3::text[])[((value - 1) % cardinality($3::text[])) + 1])::uuid,
|
||||
date_trunc('second', now()) +
|
||||
((variation.time_key % 60) + 2) * interval '1 day',
|
||||
date_trunc('second', now()) +
|
||||
((variation.time_key % 60) + 1) * interval '1 day',
|
||||
2 + ((variation.status_key + variation.time_key) % 19),
|
||||
md5(
|
||||
'wnh-scale-user-' ||
|
||||
((variation.longitude_key * 37 + variation.latitude_key) % $2 + 1)
|
||||
)::uuid,
|
||||
(($3::text[])[
|
||||
(variation.category_key % cardinality($3::text[])) + 1
|
||||
])::uuid,
|
||||
date_trunc('second', now()) - value * interval '1 second',
|
||||
date_trunc('second', now()) - value * interval '1 second'
|
||||
FROM generate_series(1, $1) AS value
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT
|
||||
((value - 1) % 20)::integer AS city_index,
|
||||
md5('wnh-scale-activity-v3-' || value) AS fixture_hash
|
||||
) AS fixture
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT
|
||||
('x' || substr(fixture.fixture_hash, 1, 8))::bit(32)::bigint
|
||||
AS longitude_key,
|
||||
('x' || substr(fixture.fixture_hash, 9, 8))::bit(32)::bigint
|
||||
AS latitude_key,
|
||||
('x' || substr(fixture.fixture_hash, 17, 4))::bit(16)::bigint
|
||||
AS status_key,
|
||||
('x' || substr(fixture.fixture_hash, 21, 4))::bit(16)::bigint
|
||||
AS visibility_key,
|
||||
('x' || substr(fixture.fixture_hash, 25, 4))::bit(16)::bigint
|
||||
AS time_key,
|
||||
('x' || substr(fixture.fixture_hash, 29, 4))::bit(16)::bigint
|
||||
AS category_key
|
||||
) AS variation
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT *
|
||||
FROM (
|
||||
|
|
@ -431,9 +512,22 @@ defmodule Mix.Tasks.Wnh.ScaleFixtures do
|
|||
(18, 'Sydney', 151.2093, -33.8688),
|
||||
(19, 'Auckland', 174.7633, -36.8485)
|
||||
) AS cities(index, name, longitude, latitude)
|
||||
WHERE cities.index = value % 20
|
||||
WHERE cities.index = fixture.city_index
|
||||
) AS city
|
||||
ON CONFLICT (id) DO NOTHING
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
structured_data = EXCLUDED.structured_data,
|
||||
location_label = EXCLUDED.location_label,
|
||||
location = EXCLUDED.location,
|
||||
location_visibility = EXCLUDED.location_visibility,
|
||||
status = EXCLUDED.status,
|
||||
starts_at = EXCLUDED.starts_at,
|
||||
join_deadline = EXCLUDED.join_deadline,
|
||||
capacity = EXCLUDED.capacity,
|
||||
creator_id = EXCLUDED.creator_id,
|
||||
category_id = EXCLUDED.category_id,
|
||||
updated_at = EXCLUDED.updated_at
|
||||
WHERE activities.structured_data @> '{"scale_fixture":true}'::jsonb
|
||||
AND activities.structured_data ->> 'scale_fixture_version' IS DISTINCT FROM '3'
|
||||
""",
|
||||
[rows, @synthetic_users, category_ids],
|
||||
timeout: :infinity,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user