• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / stories-backend / 9050524776
47%

Build:
DEFAULT BRANCH: main
Ran 12 May 2024 09:57AM UTC
Jobs 1
Files 21
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 May 2024 09:55AM UTC coverage: 47.43% (-2.2%) from 49.653%
9050524776

push

github

web-flow
Change /groups/{group id}/users route (#115)

* fix: inject user id into context in development env

* feat: add ID column to list view of Users

* feat: add role attribute to /groups/{groupId}/users response

a userId could have multiple roles, if it is present in the usergroups table in multiple rows
(with different groupId).

however, since we specify the groupId in the /group/{groupId}/users route, it makes sense that we
only retrieve users that have that groupId.

- in controller, get groupId from context
- for each user obtained from the users table, call GetUserRoleByID function from usergroups model
- store the roles obtained in an array
- pass array to updated ListFrom function from users view, which now include a role attribute
in its JSON response

* fix: DeleteUser in users model

previously, the DeleteUser function was not working as it chained
`.Delete(&user)` after `.First(&user)`. this resulted in a query as
shown, and its corresponding error:

* `ERROR: table name "users" specified more than once (SQLSTATE 42712)
[8.059ms] [rows:1] UPDATE "users" SET "deleted_at"='2024-02-12
20:52:41.02' FROM "users" WHERE id = 4 AND "users"."deleted_at" IS NULL
AND "users"."id" = 4`

the intent of `.First(&user)` was likely to store the user to be deleted
first in the `user` variable with the use of a `SELECT` SQL statement.
however, chaining another method at the end of a finisher method likely
led to some errors (see chaining
[here](https://gorm.io/docs/method_chaining.html)).

thus, this commit attempts to separate the two statements, preserving
the initial intent of storing the user to be deleted before deleting,
and then returning this user.

* feat: function to update row in users model

* feat: function to update row in usergroups model

* feat: add /users/{userID}/role put route

missing validation for parameters, but seemed unnecessary since there is
only one route with parameter validation (crea... (continued)

0 of 30 new or added lines in 3 files covered. (0.0%)

286 of 603 relevant lines covered (47.43%)

0.52 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
3
0.0
0.0% view/users/list.go
4
0.0
0.0% internal/auth/middleware.go
23
43.9
-56.1% model/usergroups.go
Jobs
ID Job ID Ran Files Coverage
1 9050524776.1 12 May 2024 09:57AM UTC 21
47.43
GitHub Action Run
Source Files on build 9050524776
  • Tree
  • List 21
  • Changed 3
  • Source Changed 3
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #9050524776
  • 840e79d2 on github
  • Prev Build on main (#8305948159)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc