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

source-academy / stories-backend
47%

Build:
DEFAULT BRANCH: main
Repo Added 30 Jun 2023 02:52AM UTC
Token B6cpVuK5i1Jlgoy7Ohc7mUKBjl7jrfwHZ regen
Build 525 Last
Files 21
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

LAST BUILD ON BRANCH main
branch: main
CHANGE BRANCH
x
Reset
Sync Branches
  • main
  • add-author-fk-non-null
  • add-basic-404-handling
  • add-db-tests
  • add-delete-routes
  • add-gorm-type-aliases
  • add-group-id-to-context
  • add-migrations-check-in-ci
  • add-names-to-users
  • add-pinned-stories
  • add-postgres-to-ci
  • add-roles-to-batch-creation
  • add-stories-tests
  • add-story-group-association
  • add-user-batch-creation
  • add-user-self-route
  • add-users-tests
  • add_course_group
  • add_group_filter_to_stories
  • bump-deps
  • change-/groups/{groupId}/users-route
  • configure-cors-via-env
  • cyy-db_create
  • decouple-users
  • dependabot/go_modules/github.com/jackc/pgx/v5-5.5.4
  • dependabot/go_modules/github.com/lestrrat-go/jwx/v2-2.0.18
  • dependabot/go_modules/github.com/lestrrat-go/jwx/v2-2.0.21
  • dependabot/go_modules/golang.org/x/crypto-0.17.0
  • deployment-docker
  • error-handling-stories
  • error-handling-users
  • finalize-deployment-setup
  • fix-cors-error
  • fix-deploy-scripts
  • fix-env-not-working
  • fix-group-id
  • fix-misc-stories-bugs
  • fix-multitenancy-system
  • fix-updating-of-stories
  • fix-user-id-context
  • go-1-21
  • grace-4
  • grace-5
  • improve-error-handling
  • inject-db-middleware
  • integrate-user-to-context
  • jwt-auth-validation
  • make-users-provider-agnostic
  • no-error-on-missing-env
  • refactor-auth
  • refactor-constants
  • refactor-db-1
  • refactor-db-scripts
  • refactor-db-test-runner
  • refactor-stories-vc
  • refactor-users-vc
  • remove-db-variable-in-users
  • rena-1
  • return-author-name-in-stories
  • setup-basic-access-control
  • setup-coveralls
  • setup-crud-permissions-check
  • setup-groups
  • setup-nullable-types
  • simplify-group-roles
  • stories-moderation
  • story-update-api-improvements
  • test-db
  • test-refactor
  • update-makefile
  • update-readme
  • validate-user-on-auth

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

Relevant lines Covered
Build:
Build:
603 RELEVANT LINES 286 COVERED LINES
0.52 HITS PER LINE
Source Files on main
  • Tree
  • List 21
  • Changed 3
  • Source Changed 3
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
9050524776 main 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 ro... push 12 May 2024 09:57AM UTC web-flow github
47.43
8305948159 main Bump github.com/jackc/pgx/v5 from 5.5.2 to 5.5.4 (#118) Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.5.2 to 5.5.4. - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc... push 16 Mar 2024 06:30AM UTC web-flow github
49.65
8305937008 main Bump github.com/lestrrat-go/jwx/v2 from 2.0.19 to 2.0.21 (#116) Bumps [github.com/lestrrat-go/jwx/v2](https://github.com/lestrrat-go/jwx) from 2.0.19 to 2.0.21. - [Release notes](https://github.com/lestrrat-go/jwx/releases) - [Changelog](https:... push 16 Mar 2024 06:27AM UTC web-flow github
49.65
8305923695 main Bump Golang to 1.21.5 (#119) * Bump golang version * Bump golangci-lint version * Update README, Dockerfiles, go.mod Reflect the updated golang version. push 16 Mar 2024 06:25AM UTC web-flow github
49.65
7872825939 main Refactor DB setup Part 1 (#105) * Separate CreateStory DB operation to own function Improves testability for unit testing. * Add sample create DB test * Separate DeleteStory DB operation to own function * Separate CreateUser DB operat... push 12 Feb 2024 01:59PM UTC web-flow github
49.65
7872789705 main Refactor DB scripts (#106) * Access error directly via variable * Remove unnecesary 'if' clause The default value of a string variable is already an empty string, and there was no additional error handling done. * Move printing logic to... push 12 Feb 2024 01:56PM UTC web-flow github
49.73
7812642533 main Bump dependencies and fix go-chi version (#112) * Fix incorrect go-chi import * Bump dependencies * Update go.sum push 07 Feb 2024 09:29AM UTC web-flow github
49.73
7593189926 main Bump golang.org/x/crypto from 0.10.0 to 0.17.0 (#111) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.10.0 to 0.17.0. - [Commits](https://github.com/golang/crypto/compare/v0.10.0...v0.17.0) --- updated-dependencies: - d... push 20 Jan 2024 08:17AM UTC web-flow github
49.73
5870095401 main Fix miscellaneous stories bugs (#103) push 15 Aug 2023 05:51PM UTC GitHub github
49.73
5867379113 main Add roles to users' batch creation (#102) push 15 Aug 2023 01:03PM UTC GitHub github
49.37
See All Builds (507)
  • Settings
  • Repo on GitHub
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