Skip to content

Conversation

Zabuzard
Copy link
Member

@Zabuzard Zabuzard commented Aug 24, 2022

Overview

The latest rework of /audit messed up some stuff and had a few bugs. This fixes it, closes #522 .

Details

The most prominent issue was incorrect usage of JDAs actions: jda.retrieveUserById(id).complete() which blocked the JDA thread and jda.getUserById(id) which looked up (outdated) cache, failing to find the user.

The issue has been fixed by properly using RestActions and their map/flatMap chains. Obviously this uglifies the code a bit - but many new helper methods to the rescue.

Apart from that, there have been some minor improvements on the UX:

  • show no page buttons if there is only a single page
  • display the last page by default (most recent entries)
  • max page size 10 for better visibility

As well as a few code readability improvements here and there, and some minor safety bugfixes like page <= 1, page >= totalPages instead of == checks.

Last, the methods have been re-ordered in time they are used to increase the readability flow - unfortunately that makes the review a bit nasty due to bad GitHub diffing.

Tests

Improvements are well tested, all edge cases included:

  • User totally unknown to the guild (= user with no actions):
    unknown user

  • User with one page actions
    one page

  • User with many pages actions (max page size was reduced to 3 for the test)
    last page

@Zabuzard Zabuzard added bug Something isn't working priority: major labels Aug 24, 2022
@Zabuzard Zabuzard self-assigned this Aug 24, 2022
@Zabuzard Zabuzard requested review from a team as code owners August 24, 2022 09:56
@Zabuzard
Copy link
Member Author

(@Taz03 for visibility)

@marko-radosavljevic
Copy link
Contributor

I like the new order of methods and refactorings. It did make the review a lot harder tho haha ❤️

@Zabuzard
Copy link
Member Author

rebase, no code change

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Zabuzard
Copy link
Member Author

Merging this, seems to be fine - if not, we can act afterwards. Want to accelerate development for this, need to get out a release for all the major improvements. Also, its weekened and I want to code a bit 😄

@Zabuzard Zabuzard merged commit dbdbd40 into develop Aug 28, 2022
@Zabuzard Zabuzard deleted the bugfix/audit_retrieve_users branch August 28, 2022 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: major
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Audit can not retrieve users anymore
2 participants