Thor77
28d047b1bf
Include parent group/stage in .index
2019-11-06 15:58:10 +01:00
Thor77
5343fcbd20
Recurisvely include all related objects
2019-11-06 11:38:24 +01:00
Daniel Schädler
b001817bac
Filter matches by state parameter
2019-10-26 00:34:04 +02:00
Daniel Schädler
33ccab8988
Return all matches also from groups
2019-10-26 00:32:14 +02:00
Daniel Schädler
a6b7a905a0
Return matches as children of tournament
2019-10-25 23:49:27 +02:00
Daniel Schädler
77c76b7a31
Add matches method to tournament
...
The method collects all matches from all stages
2019-10-25 23:47:38 +02:00
Thor77
d317585168
Add "simple" parameter to tournament show
2019-10-25 23:17:08 +02:00
Daniel Schädler
a2691b9f88
Cache group_score in variable in sort function
2019-06-18 22:35:17 +02:00
Daniel Schädler
b28561043e
Implement stages controller (GET UPDATE)
2019-06-18 22:22:10 +02:00
Daniel Schädler
54ab1570b1
Sort teams more explicitly and in the right order
2019-06-18 22:22:10 +02:00
Daniel Schädler
4925ea9d83
Make teams added to PlayoffStage configurable
2019-06-18 22:22:10 +02:00
Daniel Schädler
4e72d015ff
Implement method to check if stage is over
2019-06-18 19:22:05 +02:00
Daniel Schädler
bc0c7fddc3
Make match position randomizable
2019-06-18 19:22:05 +02:00
Daniel Schädler
88cbba440d
Implement methods to get teams sorted by their group scores
2019-06-18 19:22:05 +02:00
Daniel Schädler
c5780c2da3
Implement function to calculate the difference in points
2019-06-18 19:22:05 +02:00
Thor77
041ee4ab2c
Include bets in match resource
2019-06-18 18:51:55 +02:00
Thor77
f3b8fd4184
Use collection serializer
2019-06-18 18:51:55 +02:00
Thor77
123649a4f4
Add collection serializer for bets
2019-06-18 18:51:55 +02:00
Daniel Schädler
386155a690
Fix last Match not being stopped correctly
2019-06-18 14:09:29 +02:00
Thor77
2baefb9ae6
Associate teams only on interactor success
2019-06-18 13:29:31 +02:00
Thor77
3109308817
Fix teams not associated with created tournament
...
when choosing a group stage
2019-06-18 13:29:31 +02:00
Thor77
6640be1e9a
Add devise confirmable to user model
2019-06-18 12:27:00 +02:00
Thor77
fb2e7aa385
Add generated devise mailer views
2019-06-18 12:27:00 +02:00
Daniel Schädler
213867a827
Let context fail if population of match below fails
2019-06-17 15:02:30 +02:00
Daniel Schädler
e0da9ff7b5
Assign empty array if object_to_save is nil before pushing values to it
...
https://stackoverflow.com/questions/12163625/create-or-append-to-array-in-ruby
2019-06-17 15:02:30 +02:00
Daniel Schädler
c9e1e153df
Add interactor to advance all teams stuck in single team matches
...
After playoffs are created, before saving the stage this interactor
goes to the intermediate stage, looks for all the matches that are
:single_team matches and populates the match below with their respective
"winner".
2019-06-17 15:02:30 +02:00
Daniel Schädler
98319e9625
Assign :intermediate_stage to first stage if single_team matches present
2019-06-17 15:02:30 +02:00
Daniel Schädler
5f378f27b2
Correct position for :single_team matches
2019-06-17 15:02:30 +02:00
Daniel Schädler
36db03293e
Return a "winner" for :single_team matches
2019-06-17 15:02:30 +02:00
Daniel Schädler
8e3325bbfc
Simplify concatenation of empty stages
2019-06-17 15:02:30 +02:00
Thor77
914cfbd94d
Reword error on invalid match state
2019-06-17 13:48:50 +02:00
Thor77
175870ab42
Prevent betting on running/finished matches
2019-06-17 13:48:50 +02:00
Thor77
6d12f889c5
Add Bet serializer
2019-06-17 13:48:50 +02:00
Thor77
167a2116f1
Prevent duplicate bets on the same match
2019-06-17 13:48:50 +02:00
Thor77
76e301e920
Add BetsController
2019-06-17 13:48:49 +02:00
Thor77
b9aaccb487
Raise UserServiceError instead of StandardError
2019-06-17 13:48:49 +02:00
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