chartsWithOldData = owid.sql`select
c.id,
c.title as chart_title,
'https://ourworldindata.org/grapher/' || c.slug as link,
count(
year_max BETWEEN ${yearMin}
and ${yearMax}
) as num_chart_variables_in_range,
group_concat(pc.postId) as containing_posts
from
charts c
left join chart_variables cv on cv.chartId = c.id
left join variables v on cv.variableId = v.id
left join post_charts pc on pc.chartId = c.id
left join variable_statistics vs on vs.variableId = cv.variableId
where
vs.year_max between ${yearMin}
and ${yearMax}
group by
c.id
order by
c.id desc`