Merge branch 'toys'
This commit is contained in:
commit
6a3e232c8c
102
toys/createindex
102
toys/createindex
@ -338,8 +338,8 @@ SELECT
|
||||
tags.track,
|
||||
tags.year,
|
||||
source_files.size
|
||||
FROM source_files
|
||||
INNER JOIN mime_types
|
||||
FROM mime_types
|
||||
INNER JOIN source_files
|
||||
ON source_files.mime_type=mime_types.id
|
||||
INNER JOIN tags
|
||||
ON source_files.id=tags.source_file
|
||||
@ -573,7 +573,103 @@ unset types counts counpcts sizes sizepcts
|
||||
echo '
|
||||
|
||||
|
||||
'
|
||||
Top 5 genres:'
|
||||
maxgenrelen=5
|
||||
maxcountlen=5
|
||||
unset counts genres
|
||||
echo '
|
||||
SELECT genre,
|
||||
COUNT(*)
|
||||
FROM tags
|
||||
WHERE genre NOT NULL
|
||||
GROUP BY genre
|
||||
ORDER BY COUNT(*) DESC
|
||||
LIMIT 5;
|
||||
|
||||
SELECT "AtOM:NoMoreFiles";' >&3
|
||||
|
||||
read -u4 line
|
||||
until [[ $line == AtOM:NoMoreFiles ]]
|
||||
do
|
||||
genre="${line%%::AtOM:SQL:Sep::*}"
|
||||
rest="${line#*::AtOM:SQL:Sep::}::AtOM:SQL:Sep::"
|
||||
count="${rest%%::AtOM:SQL:Sep::*}"
|
||||
counts+=( "$count" )
|
||||
genres+=( "$genre" )
|
||||
maxcountlen=$(( ${#count} > maxcountlen ? ${#count} : maxcountlen ))
|
||||
maxgenrelen=$(( ${#genre} > maxgenrelen ? ${#genre} : maxgenrelen ))
|
||||
read -u4 line
|
||||
done
|
||||
head=$(
|
||||
printf "| # | %'${maxcountlen}s | %-${maxgenrelen}s |" \
|
||||
Count Genre
|
||||
)
|
||||
sep=${head//[^|]/-}
|
||||
sep=${sep//\|/+}
|
||||
echo "$sep"
|
||||
echo "$head"
|
||||
echo "$sep"
|
||||
for id in ${!genres[@]}
|
||||
do
|
||||
printf "| %i | %'${maxcountlen}i | %-${maxgenrelen}s |\n" \
|
||||
$(( id + 1 )) \
|
||||
"${counts[id]}" \
|
||||
"${genres[id]}"
|
||||
echo "$sep"
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user