Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/remove team locking #135

Merged
merged 30 commits into from
Oct 13, 2023
Merged

Feat/remove team locking #135

merged 30 commits into from
Oct 13, 2023

Conversation

TeddyRoncin
Copy link
Member

@TeddyRoncin TeddyRoncin commented Jun 29, 2023

Before

Players had to lock their team by hand. They couldn't unlock.

Now

The lock is automatic, it is done whenever a team is full and all the members have paied. There is also a waiting list system, that allows that, when a place is freed, teams which were locked first (but could not be accepted in the tournament because their wasn't enough place) automatically have take that place.

This means that unlocking is also automatic : if a player leaves a team, this team is unlocked (and can let its place to another team in the waiting list).

There are multiple situations in which we may need to lock or unlock teams :

  • If a player pays its basket, we have to verify each player ticket one by one, and if necessary lock the team(s) of players whose their place is in the basket (or place the teams in the waiting list). It's not only the team of the user, because we could imagine that user quit team between the moment of the creation of the basket and the callback from the bank to confirm the payment.
  • If we force-pay the place of a player, we need to verify if we can lock its team.
  • Si we refund a basket, we need to look at every player tickets, and unlock the teams of these players.
  • Si a player leaves a team, we have to unlock it.
  • If a player is kicked of a team, we have to unlock it.
  • If a player arrives in a team, if he fills the last player slot, and if its place is paid (by him or someone else), we may need to lock the team (we need to verify that each member of the team has a place before).
  • If a team is unlocked and is not in the waiting list, we remove the team that has been in the waiting list for the longest, and give it a place in the tournament.
  • If a team is disbanded, we unlock it.
  • If a team in a solo tournament is created, and that the player creating the team has already a place for this tournament, we have to lock the team

There is a schema to sum that up :
Schéma team locking drawio
(sorry, it's in french, i don't want to translate it :/)

@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (9bbbf74) 96.28% compared to head (0ddfc4b) 96.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #135      +/-   ##
==========================================
+ Coverage   96.28%   96.50%   +0.22%     
==========================================
  Files         109      108       -1     
  Lines        2260     2292      +32     
  Branches      322      330       +8     
==========================================
+ Hits         2176     2212      +36     
+ Misses         46       44       -2     
+ Partials       38       36       -2     
Files Coverage Δ
src/controllers/admin/users/replace.ts 100.00% <100.00%> (ø)
src/controllers/discord/oauth.ts 100.00% <100.00%> (+4.54%) ⬆️
src/controllers/teams/acceptRequest.ts 100.00% <100.00%> (ø)
src/controllers/teams/deleteTeam.ts 100.00% <100.00%> (ø)
src/controllers/teams/getTeam.ts 100.00% <100.00%> (ø)
src/controllers/teams/kickUser.ts 100.00% <100.00%> (ø)
src/controllers/teams/leaveTeam.ts 100.00% <100.00%> (ø)
src/controllers/teams/promoteCaptain.ts 100.00% <100.00%> (ø)
src/controllers/teams/refuseTeamRequest.ts 100.00% <100.00%> (ø)
src/controllers/teams/updateTeam.ts 100.00% <100.00%> (ø)
... and 3 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ThomasLachaux ThomasLachaux marked this pull request as ready for review August 3, 2023 09:46
@ThomasLachaux ThomasLachaux marked this pull request as draft August 3, 2023 09:53
@TeddyRoncin TeddyRoncin force-pushed the feat/remove-team-locking branch 2 times, most recently from ac3eb4d to 6958349 Compare September 30, 2023 04:03
@TeddyRoncin TeddyRoncin marked this pull request as ready for review September 30, 2023 04:03
Copy link
Contributor

@DevNono DevNono left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quelques changements mineurs à faire avant le merge

src/operations/carts.ts Outdated Show resolved Hide resolved
src/operations/carts.ts Outdated Show resolved Hide resolved
src/operations/team.ts Outdated Show resolved Hide resolved
tests/etupay/callback.test.ts Outdated Show resolved Hide resolved
Teddy Roncin and others added 19 commits October 13, 2023 17:56
refactor: when a cart is paid, refunded or forced paid, teams can be locked or unlocked
fix: we didn't check that the tournament wasn't full before locking the team

fix: we didn't check that the team was full before locking team

fix: discord was not setup
…re is no place left

fix: there was a problem when fetching player tickets in updateCart() operation
* added tests for route POST /etupay/callback
* removed tests for route POST /teams/current/lock
* added the tests
* fixed a bug where a team could be not full but force pay would still lock it
(or put it on the waiting list)
* fixed some typos in the name of the tests of the file etupay/callback.test.ts
* added some await at the end of a test to make sure instructions have finished running
* added tests
* fixed a bug in file operations/carts.ts where the check of the name of the item was done wrong
* added tests
* changed signature of the kickUser method : it now takes the user and not only its id
* fixed a bug where any type of members made the team be unlocked when they were kicked / they left
* route DELETE /teams/current/users/current no longer needs the team to not be locked
* added tests
* route DELETE /teams/current/users/:userId no longer needs the team to not be locked
* added tests
* the team can now be locked to make the request (it will still return an error tho,
but not due to the fact that it is locked, but instead that it is full)
* fixed bugs with the remake of functions kickUser and joinTeam (in the team operations file)
* added tests
* team can now be locked to delete it
* a team that is locked and deleted now lets its place to a team in the waiting list
* removed the middleware isTeamNotLocked, and its usages
* removed the tests that tested that middleware
* added tests to verify a team in the queue would be moved to the locked teams
if necessary with routes :
	- DELETE /teams/current/users/:userId
	- DELETE /teams/current/users/current
	- POST /admin/carts/:cartId/refund
* linted code
* for operation imports : replaced single function imports by gobal imports
* team can now be locked OR in the queue
* added test for that
@DevNono DevNono merged commit b7afc61 into dev Oct 13, 2023
6 checks passed
@DevNono DevNono deleted the feat/remove-team-locking branch October 13, 2023 16:26
DevNono added a commit that referenced this pull request Sep 10, 2024
* refactor: removed routes for team locking
refactor: when a cart is paid, refunded or forced paid, teams can be locked or unlocked

* fix: bugs

fix: we didn't check that the tournament wasn't full before locking the team

fix: we didn't check that the team was full before locking team

fix: discord was not setup

* feat: added a queue for teams, so that they can be locked even if there is no place left
fix: there was a problem when fetching player tickets in updateCart() operation

* test: added tests

* added tests for route POST /etupay/callback
* removed tests for route POST /teams/current/lock

* test: added tests for route POST /admin/users/:userId/force-pay

* added the tests
* fixed a bug where a team could be not full but force pay would still lock it
(or put it on the waiting list)

* fix: small corrections in the tests

* fixed some typos in the name of the tests of the file etupay/callback.test.ts
* added some await at the end of a test to make sure instructions have finished running

* test: added tests for route POST /admin/carts/:cartId/refund

* added tests
* fixed a bug in file operations/carts.ts where the check of the name of the item was done wrong

* style: linted

* feat: when a players arrives/leaves a team, it may now lock/unlock the team

* test: added tests for route DELETE /teams/current/users/current

* added tests
* changed signature of the kickUser method : it now takes the user and not only its id
* fixed a bug where any type of members made the team be unlocked when they were kicked / they left
* route DELETE /teams/current/users/current no longer needs the team to not be locked

* test: added tests for route DELETE /teams/current/users/:userId

* added tests
* route DELETE /teams/current/users/:userId no longer needs the team to not be locked

* test: tests for route POST /teams/current/join-requests/:userId

* added tests
* the team can now be locked to make the request (it will still return an error tho,
but not due to the fact that it is locked, but instead that it is full)
* fixed bugs with the remake of functions kickUser and joinTeam (in the team operations file)

* style: linted

* test: route DELETE /teams/current

* added tests
* team can now be locked to delete it
* a team that is locked and deleted now lets its place to a team in the waiting list

* fix: teams never needs to not be locked anymore

* removed the middleware isTeamNotLocked, and its usages
* removed the tests that tested that middleware

* test: added some tests

* added tests to verify a team in the queue would be moved to the locked teams
if necessary with routes :
	- DELETE /teams/current/users/:userId
	- DELETE /teams/current/users/current
	- POST /admin/carts/:cartId/refund

* style: lint

* linted code
* for operation imports : replaced single function imports by gobal imports

* feat: updated POST /admin/users/:userId/replace

* team can now be locked OR in the queue
* added test for that

* fix(tests): fix discord oauth to add support for nodejs 18+ crypto module

* fix: /tournaments route test
* a test was not passing because there was neither casters nor cashprizes on the tournaments

* fix: team lock when creating a solo team (tournament with one player team), and the player has paid

* fix: refreshed pnpm-lock.yaml

* fix: the lockfile should be useable now

* fix: tests (csgo was still used instead of cs2)

* fix: added more time in the timeout for tests POST /teams/current/join-requests/:userId

* feat: route GET /teams/current now also returns the position of the team in the queue

* fix: linted

* test: only remove the created tournament in test "GET /teams/current"

* fix: small fixes

* typo in variable name
* now returning null instead of undefined when team is not in queue

* fix: csgo to cs2

---------

Co-authored-by: AlbanSdl <[email protected]>
Co-authored-by: Noah Grigis <[email protected]>
Co-authored-by: Teddy Roncin <[email protected]>
Co-authored-by: Noé Landré <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants