Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add centralised link list in the network management #2971

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

MizukiTemma
Copy link
Member

@MizukiTemma MizukiTemma commented Aug 6, 2024

Short description

This is an updated version of #2898 with improvement sugeestion by @david-venhoff (Thank you 🙏)

Proposed changes

  • Reuse the template and view of region link list
  • Do not prefetch links in the centalized link list
  • Use the util function replace_links if users replace an URL per ✏️ in a row of the centalized link list (because we are not prefetching)*1

Side effects

  • *1 is sadly slow (but this is actually what you get when you use "Search&Replace" on the upper right corner). We can alternatively deactivate link replacement in "option" column until further performance improvement

Resolved issues

Fixes: #1443


Pull Request Review Guidelines

Copy link

codeclimate bot commented Aug 6, 2024

Code Climate has analyzed commit bb28096 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 30.7% (50% is the threshold).

This pull request will bring the total coverage in the repository to 82.7% (0.0% change).

View more on Code Climate.

deen13
deen13 previously requested changes Aug 7, 2024
Copy link
Contributor

@deen13 deen13 left a comment

Choose a reason for hiding this comment

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

I've tested the feature, and it works fine on my local machine. However, I am concerned about the use of time.sleep calls. In my experience, this is not a reliable practice.

The issue is that the action we're waiting for with time.sleep can vary in execution time depending on factors like system load, potentially causing failures in production where debugging would be challenging. Additionally, if the underlying action runs within milliseconds, time.sleep adds unnecessary wait time, causing the user to wait while the system idles.

Is there another way to wait for the signal to finish?

integreat_cms/locale/de/LC_MESSAGES/django.po Outdated Show resolved Hide resolved
@MizukiTemma
Copy link
Member Author

MizukiTemma commented Aug 7, 2024

I've tested the feature, and it works fine on my local machine. However, I am concerned about the use of time.sleep calls. In my experience, this is not a reliable practice.

The issue is that the action we're waiting for with time.sleep can vary in execution time depending on factors like system load, potentially causing failures in production where debugging would be challenging. Additionally, if the underlying action runs within milliseconds, time.sleep adds unnecessary wait time, causing the user to wait while the system idles.

Is there another way to wait for the signal to finish?

Totally agree 👀 but me neither know any handy way.
I'd suggest to solve this problem (or general performance improvement of link checker) in another issue 🤔

Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

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

Thanks! this looks mostly good to me.

An additional column for showing the region(s) of the link could be useful, but we can also open another issue for that I guess.

integreat_cms/cms/views/linkcheck/linkcheck_list_view.py Outdated Show resolved Hide resolved
integreat_cms/cms/templates/linkcheck/links_by_filter.html Outdated Show resolved Hide resolved
integreat_cms/cms/urls/protected.py Outdated Show resolved Hide resolved
@MizukiTemma
Copy link
Member Author

@david-venhoff @deen13
Thank you for your review and suggestions 😸
Now I'd like to wait for #3003 to see how it impacts the performance.

@MizukiTemma MizukiTemma added the ⛔ blocked Blocked by external dependency label Aug 20, 2024
@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch from 4cdb44e to d7b4c48 Compare August 29, 2024 10:45
@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch from d7b4c48 to f3a4d5b Compare September 5, 2024 11:27
@MizukiTemma MizukiTemma removed the ⛔ blocked Blocked by external dependency label Sep 5, 2024
@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch 2 times, most recently from 208300f to 7e52851 Compare September 11, 2024 12:43
Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

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

Awesome, this looks pretty much good to me 🎉

It might be helpful to add a new table column to the network management link list that shows the regions of the link, but maybe that should better be done in a separate pr, as it might be a bit of effort.

I think it would be useful to add some tests for e.g. the bulk actions and the search and replace functionality in network management. But that could of course be done in a separate pr.

@MizukiTemma
Copy link
Member Author

It might be helpful to add a new table column to the network management link list that shows the regions of the link, but maybe that should better be done in a separate pr, as it might be a bit of effort.

I think it would be useful to add some tests for e.g. the bulk actions and the search and replace functionality in network management. But that could of course be done in a separate pr.

Agree 👍 Opned issues #3061 and #3062

Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

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

This pr looks good to go to me 🎉

I noticed that we still perform a lot of database queries in the linkcheck view, but since the performance is acceptable right now I think we can keep it that way for now. I pushed a commit to this branch that got rid of the lowest hanging fruits though 😃

@david-venhoff david-venhoff dismissed deen13’s stale review September 19, 2024 12:40

Not working on integreat anymore

@MizukiTemma MizukiTemma requested review from PeterNerlich and removed request for deen13 September 19, 2024 14:58
Copy link
Collaborator

@PeterNerlich PeterNerlich left a comment

Choose a reason for hiding this comment

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

Did you accidentally remove model changes during squashing? Did I miss something? I get `'Url' object has no attribute 'region_links' when I try to change links

@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch from 5345776 to e2524ae Compare September 23, 2024 09:51
@MizukiTemma
Copy link
Member Author

@PeterNerlich Thank you for the review 😸 Yes, it seems I messed up while rebasing and/or squashing 😅 It should work again

Copy link
Collaborator

@PeterNerlich PeterNerlich left a comment

Choose a reason for hiding this comment

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

It appears to work now, though on closer inspection rewriting links doesn't always yield the expected results (e.g. rewriting the willkommen link with its 3 usages, replacing it to link to …/wullkommen and expecting it to appear in Invalid, also with 3 usages – instead it disappeared on me altogether) but this might just be a problem with the linkcheck library and not this PR.

Also, FYI, I saw a few errors like django.db.utils.IntegrityError: insert or update on table "linkcheck_link" violates foreign key constraint "linkcheck_link_url_id_c5f791e9_fk" followed by DETAIL: Key (url_id)=(34) is not present in table "linkcheck_url". on the console, but they as well are from within the linkcheck code and probably not caused by anything in this PR (rather, I suspect my local db state was at fault).

I hope this is the case, so I'll approve. The other comments are ideas non-essential to this PR as well.

integreat_cms/cms/templates/linkcheck/links_by_filter.html Outdated Show resolved Hide resolved
integreat_cms/cms/templatetags/linkcheck_filters.py Outdated Show resolved Hide resolved
@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch from f7fdfde to b1342ee Compare September 23, 2024 13:47
@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch 2 times, most recently from 7753833 to 18c1132 Compare September 24, 2024 09:07
Co-authored-by: David Venhoff <[email protected]>
Co-authored-by: Peter Nerlich <[email protected]>
@MizukiTemma MizukiTemma force-pushed the feature/global_link_list_performance branch from ff0cd8a to bb28096 Compare September 24, 2024 09:24
@MizukiTemma MizukiTemma merged commit 8a5eca4 into develop Sep 24, 2024
5 checks passed
@MizukiTemma MizukiTemma deleted the feature/global_link_list_performance branch September 24, 2024 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show broken links in network management
4 participants