home / russian-ads

russian-ads

Custom SQL query returning 22 rows

select
    target_id,
    targets.name,
    count(*) as n,
    json_object(
        "href", "/russian-ads/faceted-targets?targets=" || urllib_quote_plus(
            json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
        ),
        "label", json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
    ) as apply_this_facet,
    json_object(
        "href", "/russian-ads/display_ads?_targets_json=" || urllib_quote_plus(
            json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
        ),
        "label", "See " || count(*) || " ads matching " || json_insert(:targets, '$[' || json_array_length(:targets) || ']', target_id)
    ) as browse_these_ads
from ad_targets
join targets on ad_targets.target_id = targets.id
where
    json_array_length(:targets) == 0 or
    ad_id in (
        select ad_id
        from "ad_targets"
        where "ad_targets".target_id in (select value from json_each(:targets))
        group by "ad_targets".ad_id
        having count(distinct "ad_targets".target_id) = json_array_length(:targets)
    )
    and target_id not in (select value from json_each(:targets))
group by
    target_id order by n desc

Query parameters

target_idnamenapply_this_facetbrowse_these_ads
16102 interests:Human rights 1 ['1073c', '32c58', '16102'] See 1 ads matching ["1073c","32c58","16102"]
1f895 interests:Culture 1 ['1073c', '32c58', '1f895'] See 1 ads matching ["1073c","32c58","1f895"]
3e5f6 interests:Martin Luther King III 1 ['1073c', '32c58', '3e5f6'] See 1 ads matching ["1073c","32c58","3e5f6"]
59d75 language:English (US) 1 ['1073c', '32c58', '59d75'] See 1 ads matching ["1073c","32c58","59d75"]
5c628 interests:African culture 1 ['1073c', '32c58', '5c628'] See 1 ads matching ["1073c","32c58","5c628"]
5e075 language:English (UK) 1 ['1073c', '32c58', '5e075'] See 1 ads matching ["1073c","32c58","5e075"]
878ce interests:Nigerians 1 ['1073c', '32c58', '878ce'] See 1 ads matching ["1073c","32c58","878ce"]
87fac interests:Stop Police Brutality 1 ['1073c', '32c58', '87fac'] See 1 ads matching ["1073c","32c58","87fac"]
8de7c interests:Angela Davis 1 ['1073c', '32c58', '8de7c'] See 1 ads matching ["1073c","32c58","8de7c"]
a5df2 interests:Slavery in the United States 1 ['1073c', '32c58', 'a5df2'] See 1 ads matching ["1073c","32c58","a5df2"]
aabe0 interests:Black Consciousness Movement 1 ['1073c', '32c58', 'aabe0'] See 1 ads matching ["1073c","32c58","aabe0"]
ade9f interests:End Slavery Now 1 ['1073c', '32c58', 'ade9f'] See 1 ads matching ["1073c","32c58","ade9f"]
b1201 placements:News Feed on mobile devices 1 ['1073c', '32c58', 'b1201'] See 1 ads matching ["1073c","32c58","b1201"]
c3780 interests:Black is beautiful 1 ['1073c', '32c58', 'c3780'] See 1 ads matching ["1073c","32c58","c3780"]
c3b9b age:16 — 65+ 1 ['1073c', '32c58', 'c3b9b'] See 1 ads matching ["1073c","32c58","c3b9b"]
d4179 interests:African-American culture 1 ['1073c', '32c58', 'd4179'] See 1 ads matching ["1073c","32c58","d4179"]
d582c interests:Equal opportunity 1 ['1073c', '32c58', 'd582c'] See 1 ads matching ["1073c","32c58","d582c"]
e17ba interests:Malcolm X Memorial Foundation 1 ['1073c', '32c58', 'e17ba'] See 1 ads matching ["1073c","32c58","e17ba"]
e5284 interests:Malcolm X Grassroots Movement 1 ['1073c', '32c58', 'e5284'] See 1 ads matching ["1073c","32c58","e5284"]
e6200 placements:News Feed on desktop computers 1 ['1073c', '32c58', 'e6200'] See 1 ads matching ["1073c","32c58","e6200"]
e9db4 interests:Justice 1 ['1073c', '32c58', 'e9db4'] See 1 ads matching ["1073c","32c58","e9db4"]
ec3ac location:United States 1 ['1073c', '32c58', 'ec3ac'] See 1 ads matching ["1073c","32c58","ec3ac"]
Powered by Datasette · Query took 19.832ms