From 236ca5ee986f235309fe91a540e6c45ea205838c Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 20:49:17 +0200 Subject: [PATCH 1/7] Performance improvement: stop listing all versions on the homepage This is similar to #4524, where resolving a ton of URL's for versions is time consuming. This limits that by only listing the stable version, if it exists, for featured projects on our homepage --- readthedocs/templates/core/project_list_featured.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/readthedocs/templates/core/project_list_featured.html b/readthedocs/templates/core/project_list_featured.html index 9af11212fec..f9f495ebc67 100644 --- a/readthedocs/templates/core/project_list_featured.html +++ b/readthedocs/templates/core/project_list_featured.html @@ -14,10 +14,9 @@ {% else %} From 415828834a2e7c4cc401e5f703212451b3a36bb5 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 20:54:30 +0200 Subject: [PATCH 2/7] Properly check for version --- readthedocs/templates/core/project_list_featured.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readthedocs/templates/core/project_list_featured.html b/readthedocs/templates/core/project_list_featured.html index f9f495ebc67..84e21c463a7 100644 --- a/readthedocs/templates/core/project_list_featured.html +++ b/readthedocs/templates/core/project_list_featured.html @@ -15,7 +15,9 @@ From 7fd60f4bb9b99409ababdaf4955b331f20919b55 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 20:54:52 +0200 Subject: [PATCH 3/7] Handle case with no stable --- readthedocs/templates/core/project_list_featured.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readthedocs/templates/core/project_list_featured.html b/readthedocs/templates/core/project_list_featured.html index 84e21c463a7..e8adf201d03 100644 --- a/readthedocs/templates/core/project_list_featured.html +++ b/readthedocs/templates/core/project_list_featured.html @@ -17,6 +17,8 @@ {% with project.get_stable_version as version %} {% if version %}
  • {{ version.slug }}
  • + {% else %} +
  • No stable version
  • {% endif %} {% endwith %} From 1da4b77e2c8ae73c3f6be17d545cb4aead0b3959 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 21:12:06 +0200 Subject: [PATCH 4/7] Cache the version list instead --- readthedocs/templates/core/project_list_featured.html | 11 ++++------- readthedocs/templates/homepage.html | 2 ++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/readthedocs/templates/core/project_list_featured.html b/readthedocs/templates/core/project_list_featured.html index e8adf201d03..9af11212fec 100644 --- a/readthedocs/templates/core/project_list_featured.html +++ b/readthedocs/templates/core/project_list_featured.html @@ -14,13 +14,10 @@
      - {% with project.get_stable_version as version %} - {% if version %} -
    • {{ version.slug }}
    • - {% else %} -
    • No stable version
    • - {% endif %} - {% endwith %} +
    • + {% for version in project.ordered_active_versions reversed %} +
    • {{ version.slug }}
    • + {% endfor %}
    {% else %} diff --git a/readthedocs/templates/homepage.html b/readthedocs/templates/homepage.html index 9e66a3e1510..7fdb2c1756a 100644 --- a/readthedocs/templates/homepage.html +++ b/readthedocs/templates/homepage.html @@ -116,6 +116,7 @@

    Multiple versions

    {% if featured_list %} + {% cache 600 homepage featured_list %}

    {% trans "Featured Projects" %}

    @@ -128,6 +129,7 @@

    {% trans "Featured Projects" %}

    + {% endcache %} {% endif %} From 719befaa923b3c5a957a885c5086c28faac288b6 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 21:12:45 +0200 Subject: [PATCH 5/7] Dont depend on list --- readthedocs/templates/homepage.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/templates/homepage.html b/readthedocs/templates/homepage.html index 7fdb2c1756a..e17d82b022e 100644 --- a/readthedocs/templates/homepage.html +++ b/readthedocs/templates/homepage.html @@ -116,7 +116,7 @@

    Multiple versions

    {% if featured_list %} - {% cache 600 homepage featured_list %} + {% cache 600 homepage %}

    {% trans "Featured Projects" %}

    From 9b0881229f62fe4f612cbbdc9be65f8436717244 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 21:29:30 +0200 Subject: [PATCH 6/7] Load cache :) --- readthedocs/templates/homepage.html | 1 + 1 file changed, 1 insertion(+) diff --git a/readthedocs/templates/homepage.html b/readthedocs/templates/homepage.html index e17d82b022e..b8704dc19a5 100644 --- a/readthedocs/templates/homepage.html +++ b/readthedocs/templates/homepage.html @@ -3,6 +3,7 @@ {% load i18n %} {% load humanize %} {% load pagination_tags %} +{% load cache %} {% block extra_metas %} From edd7f762ea8f6b6482c06a1a33d3830633eea2b7 Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 15 Aug 2018 21:36:17 +0200 Subject: [PATCH 7/7] Better cache name --- readthedocs/templates/homepage.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs/templates/homepage.html b/readthedocs/templates/homepage.html index b8704dc19a5..9a567b6ca92 100644 --- a/readthedocs/templates/homepage.html +++ b/readthedocs/templates/homepage.html @@ -117,7 +117,7 @@

    Multiple versions

    {% if featured_list %} - {% cache 600 homepage %} + {% cache 600 homepage_featured_list %}

    {% trans "Featured Projects" %}