further optimisations for materials

1. extract seen_materials out of the loop
2. eager load file_uploads
3. about 3-4 sec less page loading time in my local, seen statistics is still the slowest part.