EHN: Optimize subprojects stats query in index.php

Modify the query to use group by to retrieve a specific stats
for all subprojects instead of query each stats for every individual
subproject.