Skip to content

Load comments with ajax#9144

Merged
ahukkanen merged 18 commits intodevelopfrom
chore/load_comments_with_ajax
May 13, 2022
Merged

Load comments with ajax#9144
ahukkanen merged 18 commits intodevelopfrom
chore/load_comments_with_ajax

Conversation

@entantoencuanto
Copy link
Copy Markdown
Contributor

🎩 What? Why?

This PR avoids loading all comments in the comments cell and loads them using javascript instead. In this way pages containing comments like the proposals or meetings show pages are loaded with similar times regardless of the number of comments they may contain.

Metrics

Data obtained from appsignal data of staging applicaction, with the show page of a meeting with 6 comments. Time in ms.

The time to load the comments partial (with a loading comments message initially) is significantly reduced.

Before optimization

  Mean Sample 1 Sample 2 Sample 3 Sample 4 Sample 5
action_view 451,2 396 463 443 507 447
active_record 97,2 76 131 83 104 92
action_controller 24,4 21 33 17 19 32
active_support 1,2 1 1 1 2 1
cells 1 1 1 1 1 1

Partials loading time:

  Mean Sample 1 Sample 2 Sample 3 Sample 4 Sample 5
comments 206,8 196 187 207 228 216

After optimization

action_view 245,4 200 208 321 296 202
active_record 59 36 36 91 91 41
action_controller 19,4 17 16 20 23 21
active_support 0,52 0,5 0,5 0,5 0,6 0,5
cells 0,32 0,3 0,3 0,3 0,4 0,3

Partials loading time:

  Mean Sample 1 Sample 2 Sample 3 Sample 4 Sample 5
comments 12,4 11 9 18 16 8

📌 Related Issues

Link your PR to an issue

Testing

Describe the best way to test or validate your PR.

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

Please add screenshots of the changes you're proposing
Description

♥️ Thank you!

@entantoencuanto entantoencuanto changed the title Chore/load comments with ajax Load comments with ajax Apr 6, 2022
@ferblape ferblape force-pushed the chore/load_comments_with_ajax branch from 45a3f0c to 4d1b335 Compare April 23, 2022 03:11
@entantoencuanto entantoencuanto force-pushed the chore/load_comments_with_ajax branch from 55bf7c9 to ee38c41 Compare April 27, 2022 08:57
@entantoencuanto entantoencuanto marked this pull request as ready for review April 27, 2022 13:03
@entantoencuanto entantoencuanto force-pushed the chore/load_comments_with_ajax branch from 05a1571 to 0f2977b Compare April 27, 2022 13:38
ferblape
ferblape previously approved these changes Apr 28, 2022
Copy link
Copy Markdown
Contributor

@ahukkanen ahukkanen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice improvement, thanks a lot @entantoencuanto !

I just noticed one potential issue in the initial load when inspecting the network tab of the browser. I noticed that it is doing a duplicate AJAX request when the component initially loads. Please see the comments below.

Very nice

@andreslucena andreslucena added the project: PWA Barcelona City Council contract label May 5, 2022
@ahukkanen ahukkanen merged commit 8da574f into develop May 13, 2022
@ahukkanen ahukkanen deleted the chore/load_comments_with_ajax branch May 13, 2022 15:42
@ferblape ferblape mentioned this pull request May 19, 2022
12 tasks
andreslucena pushed a commit that referenced this pull request May 19, 2022
* Send refresh comments request on comments component initialization

* Load empty comments list in comments cell unless single_comment?

* Add comments loading message

* Fix lint errors

* Don't instantiate counter when there's no textarea

* Lint offenses

* Don't call on null selector

* Lint JS

* Restore changes

* No need to change hide class because now it's loaded automatically from ajax

* Recover hide class removal on replies

* Add a concern to deal with parent/child recursive resources using pure postgresql queries and use in comments

* Ignore hidden comments when there are not comments at the same level or lower to show

* Change comment_cell methods to use descendants recursive query

* Fix test

Currently the comments list is initially empty in the cell and they are
loaded using AJAX

* Take into account automatic translations in comments component

* Define a method to fetch comments

* Avoid duplicated requests in comments component

Co-authored-by: Fernando Blat <fernando@blat.es>
andreslucena pushed a commit that referenced this pull request May 19, 2022
* Send refresh comments request on comments component initialization

* Load empty comments list in comments cell unless single_comment?

* Add comments loading message

* Fix lint errors

* Don't instantiate counter when there's no textarea

* Lint offenses

* Don't call on null selector

* Lint JS

* Restore changes

* No need to change hide class because now it's loaded automatically from ajax

* Recover hide class removal on replies

* Add a concern to deal with parent/child recursive resources using pure postgresql queries and use in comments

* Ignore hidden comments when there are not comments at the same level or lower to show

* Change comment_cell methods to use descendants recursive query

* Fix test

Currently the comments list is initially empty in the cell and they are
loaded using AJAX

* Take into account automatic translations in comments component

* Define a method to fetch comments

* Avoid duplicated requests in comments component

Co-authored-by: Fernando Blat <fernando@blat.es>
eliegaboriau pushed a commit to eliegaboriau/decidim that referenced this pull request Oct 25, 2022
* Send refresh comments request on comments component initialization

* Load empty comments list in comments cell unless single_comment?

* Add comments loading message

* Fix lint errors

* Don't instantiate counter when there's no textarea

* Lint offenses

* Don't call on null selector

* Lint JS

* Restore changes

* No need to change hide class because now it's loaded automatically from ajax

* Recover hide class removal on replies

* Add a concern to deal with parent/child recursive resources using pure postgresql queries and use in comments

* Ignore hidden comments when there are not comments at the same level or lower to show

* Change comment_cell methods to use descendants recursive query

* Fix test

Currently the comments list is initially empty in the cell and they are
loaded using AJAX

* Take into account automatic translations in comments component

* Define a method to fetch comments

* Avoid duplicated requests in comments component

Co-authored-by: Fernando Blat <fernando@blat.es>
@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants