# create the png (and query the db to populate a csv file...) for Arch Linux
#
create_archlinux_png_from_table(){
echo"Checking whether to update $2..."
# $1 = id of the stats table
# $2 = image file name
echo"${FIELDS[$1]}">${TABLE[$1]}.csv
# prepare query
WHERE_EXTRA="WHERE suite = '$SUITE'"
if[$1-eq 0 ]||[$1-eq 2 ];then
# TABLE[0+2] have a architecture column:
WHERE_EXTRA="$WHERE_EXTRA AND architecture = '$ARCH'"
fi
# run query
if[$1-eq 1 ];then
# not sure if it's worth to generate the following query...
WHERE_EXTRA="AND architecture='$ARCH'"
# This query became much more obnoxious when gaining
# compatibility with postgres
query_to_csv "SELECT stats.datum,
COALESCE(reproducible_stretch,0) AS reproducible_stretch,
COALESCE(reproducible_buster,0) AS reproducible_buster,
COALESCE(reproducible_unstable,0) AS reproducible_unstable,
COALESCE(reproducible_experimental,0) AS reproducible_experimental,
COALESCE(FTBR_stretch,0) AS FTBR_stretch,
COALESCE(FTBR_buster,0) AS FTBR_buster,
COALESCE(FTBR_unstable,0) AS FTBR_unstable,
COALESCE(FTBR_experimental,0) AS FTBR_experimental,
COALESCE(FTBFS_stretch,0) AS FTBFS_stretch,
COALESCE(FTBFS_buster,0) AS FTBFS_buster,
COALESCE(FTBFS_unstable,0) AS FTBFS_unstable,
COALESCE(FTBFS_experimental,0) AS FTBFS_experimental,
COALESCE(other_stretch,0) AS other_stretch,
COALESCE(other_buster,0) AS other_buster,
COALESCE(other_unstable,0) AS other_unstable,
COALESCE(other_experimental,0) AS other_experimental
FROM (SELECT s.datum,
COALESCE((SELECT e.reproducible FROM stats_builds_per_day AS e WHERE s.datum=e.datum AND suite='stretch' $WHERE_EXTRA),0) AS reproducible_stretch,
COALESCE((SELECT e.reproducible FROM stats_builds_per_day AS e WHERE s.datum=e.datum AND suite='buster' $WHERE_EXTRA),0) AS reproducible_buster,
COALESCE((SELECT e.reproducible FROM stats_builds_per_day AS e WHERE s.datum=e.datum AND suite='unstable' $WHERE_EXTRA),0) AS reproducible_unstable,
COALESCE((SELECT e.reproducible FROM stats_builds_per_day AS e WHERE s.datum=e.datum AND suite='experimental' $WHERE_EXTRA),0) AS reproducible_experimental,
(SELECT e.FTBR FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='stretch' $WHERE_EXTRA) AS FTBR_stretch,
(SELECT e.FTBR FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='buster' $WHERE_EXTRA) AS FTBR_buster,
(SELECT e.FTBR FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='unstable' $WHERE_EXTRA) AS FTBR_unstable,
(SELECT e.FTBR FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='experimental' $WHERE_EXTRA) AS FTBR_experimental,
(SELECT e.FTBFS FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='stretch' $WHERE_EXTRA) AS FTBFS_stretch,
(SELECT e.FTBFS FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='buster' $WHERE_EXTRA) AS FTBFS_buster,
(SELECT e.FTBFS FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='unstable' $WHERE_EXTRA) AS FTBFS_unstable,
(SELECT e.FTBFS FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='experimental' $WHERE_EXTRA) AS FTBFS_experimental,
(SELECT e.other FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='stretch' $WHERE_EXTRA) AS other_stretch,
(SELECT e.other FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='buster' $WHERE_EXTRA) AS other_buster,
(SELECT e.other FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='unstable' $WHERE_EXTRA) AS other_unstable,
(SELECT e.other FROM stats_builds_per_day e WHERE s.datum=e.datum AND suite='experimental' $WHERE_EXTRA) AS other_experimental
FROM stats_builds_per_day AS s GROUP BY s.datum) as stats
ORDER BY datum">>${TABLE[$1]}.csv
elif[$1-eq 2 ];then
# just make a graph of the oldest reproducible build (ignore FTBFS and FTBR)
query_to_csv "SELECT datum, oldest_reproducible FROM ${TABLE[$1]}${WHERE_EXTRA} ORDER BY datum">>${TABLE[$1]}.csv
else
query_to_csv "SELECT ${FIELDS[$1]} from ${TABLE[$1]}${WHERE_EXTRA} ORDER BY datum">>${TABLE[$1]}.csv
fi
# this is a gross hack: normally we take the number of colors a table should have...
# for the builds_age table we only want one color, but different ones, so this hack: