home / content

Menu
  • Sign in with GitHub

Timeline Count

Custom SQL query returning 1 row (hide)

with combined as (
  select
    'news' as item_type,
    null as title,
    body
  from news
  where coalesce(nullif(cast(:news as text), ''), '1') = '1'
  union all
  select
    'blog' as item_type,
    title,
    coalesce(summary, '') as body
  from blog_posts
  where coalesce(nullif(cast(:blog as text), ''), '1') = '1'
  union all
  select
    'release' as item_type,
    repos.name || ' ' || releases.tag_name as title,
    coalesce(releases.body, '') as body
  from releases
    join repos on releases.repo = repos.id
  where releases.draft = 0
    and coalesce(nullif(cast(:release as text), ''), '1') = '1'
)
select count(*) as total
from combined
where coalesce(:q, '') = ''
   or title like '%' || :q || '%'
   or body like '%' || :q || '%'

Parameters

Edit SQL

This data as json, CSV

total
1953
Powered by Datasette