Thor77
2f0127897e
Add UserService
2019-06-17 13:48:49 +02:00
Thor77
f3431e8442
Add bet model
...
* has_many relations in all belonging models
* specs for relations in existing models
* association specs for bet model
2019-06-17 13:48:49 +02:00
Daniel Schädler
db70e33882
Assign number to each group
2019-06-17 13:37:06 +02:00
Daniel Schädler
a74030a7ef
Implement GroupsController
2019-06-16 13:22:15 +02:00
Daniel Schädler
2e336262aa
Add state to stage
...
This state is required to stop the group stage and trigger playoff
generation, it is (for now) irrelevant for anything other than that.
2019-06-13 13:21:24 +02:00
Daniel Schädler
5004dec39a
Change playoff transition relevant attributes of tournament on update
...
They are only updated when playoff_teams_amount changed alone
2019-06-13 13:21:24 +02:00
Daniel Schädler
e936fd40b2
Convert integer parameters to actual integers
...
Apparently rails thinks this is the way to do it.
2019-06-13 13:21:24 +02:00
Daniel Schädler
b408d1dd37
Ignore validity of matching params if only playoff_teams_amount changed
...
If only playoff_teams_amount changed, the other two will be overwritten
anyways.
2019-06-13 13:21:24 +02:00
Daniel Schädler
6a060651a4
Validate update parameters
...
playoff_teams_amount, instant_finalists_amount and
intermediate_round_participants_amount need to make sense together
2019-06-13 13:21:24 +02:00
Daniel Schädler
f04c11427a
Assign default values on Group Stage creation
...
default values are assigned to instant_finalists_amount and
intermediate_round_participants_amount depending on playoff_teams_amount and group amount
2019-06-13 13:21:24 +02:00
Daniel Schädler
4d5d7bc812
Only allow positive powers of two for playoff_teams_amount
2019-06-13 13:21:24 +02:00
Daniel Schädler
f5b610703c
Add two new parameters to tournament
...
instant_finalists_amount is the amount of teams that instantly are in
the finals after the group stage ends.
intermediate_round_participants_amount is the amount of teams that have
a chance to advance after group stage but must play a relegation game to
actually do so.
Both of these values need to match, so that
instant_finalists_amount + (intermediate_round_participants_amount / 2)
is a power of 2. Or to be more precise, the power of two that is saved
in playoff_teams_amount of the tournament.
2019-06-13 13:21:24 +02:00
Daniel Schädler
c1b2b72ca3
Simplify controller code
...
Matches update now gets rolled back via a Transaction
2019-06-05 17:05:58 +02:00
Daniel Schädler
68535b89fc
Prevent matches from being stopped without a winner in playoffs
2019-06-05 17:05:58 +02:00
Daniel Schädler
bd2af09339
Add field to tournament containing playoff_teams_amount
...
This field represents how many teams advance into playoff stage after
the group stage has ended.
2019-06-05 16:46:06 +02:00
Daniel Schädler
96398706ea
Add GroupScore objects for every team to the group stage
2019-06-05 09:49:21 +02:00
Daniel Schädler
957788651c
Update group_scores on match_score change if match is a group match
2019-06-05 09:49:21 +02:00
Daniel Schädler
564cec2820
Add method to check if match_score is part of a group match
2019-06-05 09:49:21 +02:00
Daniel Schädler
d556e3e833
Implement update_group_score method
...
This method calculates all the group scores of the group given to it
2019-06-05 09:49:21 +02:00
Daniel Schädler
752beefca6
Correctly handle matches that are not started yet
2019-06-05 09:49:21 +02:00
Daniel Schädler
c1dc43948b
Fix typo in received_points
2019-06-05 09:49:21 +02:00
Daniel Schädler
bd0f8c7fd2
Replace guard clauses with ternary operator
...
@thor77 apparently thinks this is better then it was before.. i don't
really care so here we go ¯\_(ツ)_/¯
2019-06-05 09:49:20 +02:00
Daniel Schädler
e868e936e4
Implement Methods returning points of teams per match
...
These methods return group_points scored_points and received_points
respectively when given a team that is present in the match
They return 0 when given a team that isn't contesting in that match
2019-06-05 09:26:11 +02:00
Daniel Schädler
a4ea0cf979
Move self methods into self block
2019-06-05 09:26:11 +02:00
Thor77
b07447aaae
Permit username key for account update
2019-06-04 09:55:45 +02:00
Thor77
91fe9dba16
Add winner attribute to match serializer
2019-05-28 23:18:55 +02:00
Thor77
12005b95fa
Fix group score not serialized correctly
...
when returned from statistics endpoint
2019-05-28 22:24:03 +02:00
Daniel Schädler
6f44823bc6
Change match state of match below
2019-05-26 20:15:59 +02:00
Daniel Schädler
8bdcd51e66
Move all methods in playoff_stage_service into self block
2019-05-26 20:15:59 +02:00
Daniel Schädler
645f3d0800
Return changed objects in populate_match_below
2019-05-26 20:15:58 +02:00
Daniel Schädler
95bed3959f
Actually make singleton_methods private
...
(Rubocop told me so and I trust the police)
2019-05-26 20:15:58 +02:00
Daniel Schädler
cda7d168f5
Save match_scores explicitly after changing them
2019-05-26 20:15:58 +02:00
Daniel Schädler
93cea002f9
Change the way, existing match_scores are handled
2019-05-26 20:15:58 +02:00
Daniel Schädler
2b39bb1521
Move populating the match below to when the state is changed
2019-05-26 20:15:58 +02:00
Daniel Schädler
7a9da4e22d
Rearrange methods in playoff_stage_service
2019-05-26 20:15:58 +02:00
Daniel Schädler
27d6269f94
Rearrange new methods into one to split it later on
2019-05-26 20:15:58 +02:00
Daniel Schädler
4e907b1fc8
Improve Formatting in playoff_stage_service (I guess)
...
... Rubocop wanted it that way
2019-05-26 20:15:16 +02:00
Daniel Schädler
e4c868c150
Fix second match winner advancing, even if match is not finished
2019-05-26 20:15:16 +02:00
Daniel Schädler
12daf53599
Check for errors while populating the match below
2019-05-26 20:15:16 +02:00
Daniel Schädler
fc69c6e6e6
Implement PopulateMatchBelow Interactor & Organizer
2019-05-26 20:15:16 +02:00
Daniel Schädler
c9b07f7033
Implement populate_match_below method
2019-05-26 20:14:13 +02:00
Daniel Schädler
2c9e06946d
Call populate_match_below when a match is finished
2019-05-26 20:14:13 +02:00
Daniel Schädler
2f77d2d25b
Add winner method to match
2019-05-26 20:14:13 +02:00
Daniel Schädler
280b0c1dec
Change status of Match to only represent being finished
...
The winner will be a attribute of the Match instead of something
that is written in its status.
2019-05-26 20:14:13 +02:00
Daniel Schädler
1a2caaedef
Remove unused evaluate status method
2019-05-26 20:14:13 +02:00
Daniel Schädler
9cfead9723
Make save_application_record_object work with arrays
2019-05-26 20:14:13 +02:00
Daniel Schädler
8388af20f0
Generalize tournament save interactor
...
It now is responsible for saving all ApplicationRecord objects to the
database. This will reduce code duplication one we have other objects
that need to be saved. (As we will soon need to save individual matches)
2019-05-26 20:14:13 +02:00
Daniel Schädler
4a7e207e9b
Fix missing title in unused E-Mail Template
2019-05-26 17:41:11 +02:00
Daniel Schädler
b36e3c4251
Delegate owner of team to tournament again
2019-05-22 09:25:07 +02:00
Daniel Schädler
03d7369a1c
Remove link between team.owner and tournament
2019-05-22 09:25:07 +02:00
Thor77
37b63cace2
Use methods instead of attributes
...
because each attribute is only used once and updating a Stage should
reflect those changes
2019-05-16 20:53:05 +02:00
Thor77
d6a691fe5a
Add documentation to sort_group_scores
2019-05-16 20:53:05 +02:00
Thor77
99bfe6ed70
Add StatisticsController
2019-05-16 20:53:04 +02:00
Thor77
bdcfbe934b
Add StatisticsService
2019-05-16 20:53:04 +02:00
Thor77
894608c19e
Fix Stage.teams returning nil on error
2019-05-16 20:53:03 +02:00
Thor77
27c4bcacc8
Respond with 501 for state param 'finished'
...
(501 = NOT IMPLEMENTED)
2019-05-07 18:41:53 +02:00
Thor77
3876f57d32
Add methods and specs to update a match
2019-05-07 18:41:53 +02:00
Thor77
436adde706
Set global match var for reuse by other methods
2019-05-07 18:41:52 +02:00
Thor77
1b9db61c22
Add owner method to Stage, Group and Match
2019-05-07 18:41:52 +02:00
Daniel Schädler
f7ed4b549d
Destroying all Readability.
...
Noone will ever be able to read this code again.
2019-05-04 20:54:08 +02:00
Daniel Schädler
23249ee93b
Build Matches without saving directly to database
2019-05-04 20:34:57 +02:00
Daniel Schädler
6a2c71bad7
Fix stage.team method not returning teams for playoff stages
2019-05-04 20:34:57 +02:00
Daniel Schädler
db1518bdbd
Raise exceptions upon error in group_stage_service
2019-05-04 20:34:57 +02:00
Daniel Schädler
bfadc7a6af
Dry out Tournaments Controller
2019-05-04 20:34:57 +02:00
Daniel Schädler
fdac71a9f1
Unnecessary variable assignment
2019-05-04 20:34:57 +02:00
Daniel Schädler
9053251706
Document group_stage generation parameter preparation
2019-05-04 20:34:57 +02:00
Daniel Schädler
f9b96cbee2
Indicate the groups variable being changed within the method
2019-05-04 20:34:57 +02:00
Daniel Schädler
74e9139b33
Removes unnecessary check
2019-05-04 20:34:57 +02:00
Daniel Schädler
acfc388da4
Implements group stage tournament creation
2019-05-04 20:34:57 +02:00
Daniel Schädler
f9b1b603f0
Permits "group_stage" as valid parameter for a create request
2019-05-04 20:34:57 +02:00
Daniel Schädler
a842e0db3c
Add group stage service
...
This service is responsible for all actions concerning the group stage
It returns false if no groups are given to generate_group_stage method
This prevents dividing by zero in the next line
2019-05-04 20:34:57 +02:00
Daniel Schädler
f7919ec0c6
Adds Organizer to Add a group stage to a tournament and save it
2019-05-04 20:34:57 +02:00
Daniel Schädler
83cd4ed340
Let Context Fail if there are any stages already in the tournament
2019-05-04 20:34:57 +02:00
Daniel Schädler
548d9241c4
Add Interactor to add group stage to a tournament
2019-05-04 20:34:57 +02:00
Daniel Schädler
26b8ff96c9
Add teams method to group,match,stage
...
It returns the unique teams that compete within the object
2019-05-04 20:34:57 +02:00
Thor77
2b72d0457e
Implement type parameter for tournaments index
2019-04-24 22:49:48 +02:00
Daniel Schädler
d3d572ea1b
Change return for 0 teams to exception
2019-04-23 14:21:29 +02:00
Daniel Schädler
a30ff860e9
Return a valid list of matches for 1 team
2019-04-23 14:19:36 +02:00
Daniel Schädler
38425df823
Only support stage count calculation for 1+ teams
2019-04-23 14:19:36 +02:00
Daniel Schädler
49a6545af9
Fix start point for stages with matchnumbers that are not powers of 2
2019-04-23 14:19:36 +02:00
Daniel Schädler
1c2d051364
Subtract one off required stages if the number of teams is a power of 2
...
This way we now calculate the right amount of stages for every number.
(I would test every number, but Jonas won't let me write tests for all of them..)
2019-04-23 14:19:36 +02:00
Thor77
22e547befa
Add validatable attribute to User model
...
to get email and password (existence) validation
2019-04-23 10:47:50 +02:00
Thor77
157844b4ae
Catch missing parameter exceptions to render error
2019-04-16 13:24:58 +02:00
Thor77
08d2ae59a5
Check teams array before calling create method
2019-04-16 13:24:58 +02:00
Thor77
417b296d0e
Override registration and session render methods
...
to remove wrapping data-element
2019-04-16 11:01:31 +02:00
Thor77
a2e35e1710
Create teams with only name attribute
2019-04-08 11:16:51 +02:00
Thor77
ec4e2797c2
Call tournament generation for create endpoint
...
and associate given team ids with the new tournament
2019-04-07 19:24:17 +02:00
Thor77
e78de72f3d
Fix id and model logged as unpermitted params
...
by slicing selected attributes from params and permitting them all.
2019-04-07 16:09:59 +02:00
Thor77
8b07c46acd
Permit parameters without root key
2019-04-07 14:00:06 +02:00
Daniel Schädler
7f87ce9230
Add documentation for all services
2019-04-03 15:33:59 +02:00
Thor77
d7910c093b
Update user model to extend devise models
2019-04-03 09:43:04 +02:00
Thor77
5126e5ae76
Add position to MatchSerializer
2018-12-11 17:14:43 +01:00
Thor77
d1bc3de6b0
Add owner_username attribute to Tournament
...
displaying the username of the user owning the tournament
2018-12-11 17:14:43 +01:00
Thor77
32c012af32
Use plain params-hash instead of custom helper
...
for deserialization of create/update-data
2018-12-11 17:12:55 +01:00
Thor77
2f828542ef
Alias recieved_points to received_points
...
to avoid a change of the db schema for now
2018-12-11 17:12:55 +01:00
Thor77
5076197f78
Recursively include all relations for a tournament
2018-12-11 17:12:55 +01:00
Thor77
e3bbe2b773
Include description only in full Tournament
2018-12-11 17:12:55 +01:00
Thor77
baf1acc10b
Include team-relation in MatchScoreSerializer
2018-12-11 17:12:55 +01:00
Thor77
2f4df349c0
Add GroupScore, Group and StageSerializer
2018-12-11 17:12:55 +01:00
Thor77
bfe1c07fdc
Include id-attribute for all serializers
2018-12-11 17:12:55 +01:00