createindex: Top 10 artists

This commit is contained in:
Vincent Riquer 2013-10-28 13:36:04 +01:00
parent 666b9a0ab4
commit 3080d9de45

View File

@ -619,7 +619,57 @@ do
done
unset line genre count rest genres counts maxgenrelen maxcountlen
'
echo '
Top 10 artists:'
maxartistlen=6
maxcountlen=5
unset counts artists
echo '
SELECT artist,
COUNT(*)
FROM tags
WHERE artist NOT NULL
GROUP BY artist
ORDER BY COUNT(*) DESC
LIMIT 10;
SELECT "AtOM:NoMoreFiles";' >&3
read -u4 line
until [[ $line == AtOM:NoMoreFiles ]]
do
artist="${line%%::AtOM:SQL:Sep::*}"
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
count="${rest%%::AtOM:SQL:Sep::*}"
counts+=( "$count" )
artists+=( "$artist" )
maxcountlen=$(( ${#count} > maxcountlen ? ${#count} : maxcountlen ))
maxartistlen=$(( ${#artist} > maxartistlen ? ${#artist} : maxartistlen ))
read -u4 line
done
head=$(
printf "| # | %'${maxcoutlen}s | %-${maxartistlen}s |" \
Count Artist
)
sep=${head//[^|]/-}
sep=${sep//\|/+}
echo "$sep"
echo "$head"
echo "$sep"
for id in ${!artists[@]}
do
printf "| %2i | %'${maxcountlen}i | %-${maxartistlen}s |\n" \
$(( id + 1 )) \
"${counts[id]}" \
"${artists[id]}"
echo "$sep"
done
unset line artist count rest artists counts maxartistlen maxcountlen
echo '
File formats:'
echo '
SELECT COUNT(*),SUM(size)
FROM source_files