NOISSUE - Refactor listing for rules and reports#433
Merged
dborovcanin merged 10 commits intoabsmach:mainfrom Mar 16, 2026
Merged
NOISSUE - Refactor listing for rules and reports#433dborovcanin merged 10 commits intoabsmach:mainfrom
dborovcanin merged 10 commits intoabsmach:mainfrom
Conversation
e4d78e3 to
8edaff4
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #433 +/- ##
==========================================
- Coverage 25.29% 22.98% -2.32%
==========================================
Files 142 25 -117
Lines 20549 4364 -16185
==========================================
- Hits 5198 1003 -4195
+ Misses 14913 3290 -11623
+ Partials 438 71 -367 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9c5cc43 to
e34cbc4
Compare
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
7852c33 to
9616066
Compare
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
dborovcanin
requested changes
Mar 16, 2026
Contributor
dborovcanin
left a comment
There was a problem hiding this comment.
Add listing rules and reports service tests for SuperAdmin.
re/postgres/repository.go
Outdated
Comment on lines
+429
to
+454
| pgData := "" | ||
| if pm.Limit != 0 { | ||
| pgData = "LIMIT :limit" | ||
| } | ||
| if pm.Offset != 0 { | ||
| pgData += " OFFSET :offset" | ||
| } | ||
| pq := pageRulesQuery(pm) | ||
|
|
||
| dir := api.DescDir | ||
| if pm.Dir == api.AscDir { | ||
| dir = api.AscDir | ||
| } | ||
|
|
||
| orderClause := "" | ||
|
|
||
| switch pm.Order { | ||
| case api.NameKey: | ||
| orderClause = fmt.Sprintf("ORDER BY name %s, id %s", dir, dir) | ||
| case api.CreatedAtOrder: | ||
| orderClause = fmt.Sprintf("ORDER BY created_at %s, id %s", dir, dir) | ||
| case api.UpdatedAtOrder: | ||
| orderClause = fmt.Sprintf("ORDER BY COALESCE(updated_at, created_at) %s, id %s", dir, dir) | ||
| default: | ||
| orderClause = fmt.Sprintf("ORDER BY COALESCE(updated_at, created_at) %s, id %s", dir, dir) | ||
| } |
Contributor
There was a problem hiding this comment.
This is a lot of duplication from the previous method. Try to extract to shared helper.
Contributor
There was a problem hiding this comment.
The same goes for reports.
re/service.go
Outdated
Comment on lines
+178
to
+190
| switch session.SuperAdmin { | ||
| case true: | ||
| page, err := re.repo.ListAllRules(ctx, pm) | ||
| if err != nil { | ||
| return Page{}, errors.Wrap(svcerr.ErrViewEntity, err) | ||
| } | ||
| return page, nil | ||
| default: | ||
| page, err := re.repo.ListUserRules(ctx, session.UserID, pm) | ||
| if err != nil { | ||
| return Page{}, errors.Wrap(svcerr.ErrViewEntity, err) | ||
| } | ||
| return page, nil |
Contributor
There was a problem hiding this comment.
Use simpler if. Same goes for reports.
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
dborovcanin
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
What does this do?
Which issue(s) does this PR fix/relate to?
Have you included tests for your changes?
Did you document any new/modified feature?
Notes