Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 052b5592 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Fix first page render

This pathc fixes the render of the first page. This one have to display
general results plus a sample of 5 images and 2 videos.

Previously, torrent and videos results were included.

This change is related to the comment https://gitlab.e.foundation/e/cloud/my-spot/issues/30#note_10233
parent a35c0ff1
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -510,16 +510,10 @@ def index():

    results_copy = copy.deepcopy(search_data.results)
    if is_general_first_page:
        for res in results_copy:
            if res.get('category') == 'images':
                if len(images) < 5:
                    images.append(res)
                results_copy.remove(res)
            elif res.get('category') == 'videos':
                if len(videos) < 2:
                    videos.append(res)
                results_copy.remove(res)
            elif res.get('category') is None:
        images = [r for r in results_copy if r.get('category') == 'images'][:5]
        videos = [r for r in results_copy if r.get('category') == 'videos'][:2]
        for res in search_data.results:
            if res.get('category') != 'general':
                results_copy.remove(res)

    # output