• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
You are now the owner of this repo.

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: SELECT
CHANGE BRANCH
x
Sync Branches
  • No branch selected
  • 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
  • main
  • 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
Detailed source file information is not available for this build.

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
9050394925 change-/groups/{groupId}/users-route Refactor logic Pull #115 12 May 2024 09:27AM UTC RichDom2185 github
47.43
9050273125 change-/groups/{groupId}/users-route Use range iterator for users list view Pull #115 12 May 2024 09:08AM UTC RichDom2185 github
47.04
8656226807 stories-moderation Run go mod tidy Pull #120 12 Apr 2024 02:46AM UTC keyansheng github
47.69
8549834697 setup-nullable-types Merge branch 'main' into setup-nullable-types Pull #104 04 Apr 2024 05:40AM UTC web-flow github
49.65
8445005361 stories-moderation Revert random added and deleted newlines and comments Pull #120 27 Mar 2024 12:58AM UTC keyansheng github
47.69
8442450825 stories-moderation Fix migration name Pull #120 26 Mar 2024 08:26PM UTC keyansheng github
47.69
8442415791 stories-moderation Fix migration ordering Pull #120 26 Mar 2024 08:23PM UTC keyansheng github
47.69
8442349798 stories-moderation Fix TestCreateStory/can_create_without_group fail Pull #120 26 Mar 2024 08:18PM UTC keyansheng github
47.69
8439610498 stories-moderation Fix migration ordering Pull #120 26 Mar 2024 04:37PM UTC keyansheng github
45.32
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

© 2026 Coveralls, Inc