Skip to content

Commit

Permalink
2b2t session time limit api
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Jan 21, 2025
1 parent bd5280b commit a04c717
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 3 deletions.
33 changes: 33 additions & 0 deletions src/main/java/vc/controller/LimitsController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package vc.controller;

import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Tags({@Tag(name = "Limits")})
@RestController
public class LimitsController {

public record SessionTimeLimitResponse(int hours) {
public static final SessionTimeLimitResponse INSTANCE = new SessionTimeLimitResponse(8);
}

@GetMapping("/limits/session-time-limit")
@ApiResponses(value =
@ApiResponse(
responseCode = "200",
description = """
Return the current 2b2t game session time limit for non-priority players.
When this limit is reached, the player will be kicked from the server.
"""
)
)
public ResponseEntity<SessionTimeLimitResponse> getNonPrioKickTimeLimit() {
return ResponseEntity.ok(SessionTimeLimitResponse.INSTANCE);
}
}
2 changes: 0 additions & 2 deletions src/main/java/vc/controller/QueueController.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ public ResponseEntity<QueueLengthHistory> queueHistory() {
}

@GetMapping("/queue/eta-equation")
@RateLimiter(name = "queue-eta-equation")
@Cacheable("queue-eta-equation")
@ApiResponses(value = {
@ApiResponse(
responseCode = "200",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7750,6 +7750,9 @@
{
"type": "org.jooq.util.yugabytedb.YugabyteDBDataType"
},
{
"type": "org.jspecify.annotations.NullMarked"
},
{
"type": "org.neo4j.driver.Driver"
},
Expand Down Expand Up @@ -17285,6 +17288,10 @@
"name": "killsTopMonthTest",
"parameterTypes": []
},
{
"name": "nonPrioTimeLimitsTest",
"parameterTypes": []
},
{
"name": "playerLookupCraftheadTest",
"parameterTypes": []
Expand Down Expand Up @@ -18450,6 +18457,36 @@
}
]
},
{
"type": "vc.controller.LimitsController",
"allDeclaredFields": true,
"methods": [
{
"name": "<init>",
"parameterTypes": []
},
{
"name": "getNonPrioKickTimeLimit",
"parameterTypes": []
}
]
},
{
"type": "vc.controller.LimitsController$SessionTimeLimitResponse",
"allDeclaredFields": true,
"methods": [
{
"name": "<init>",
"parameterTypes": [
"int"
]
},
{
"name": "hours",
"parameterTypes": []
}
]
},
{
"type": "vc.controller.NamesController",
"allDeclaredFields": true,
Expand Down

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/test/java/vc/ApiTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ public void killsTopMonthTest() {
assertFalse(killsTopMonthResponse.players().isEmpty());
}

@Test
public void nonPrioTimeLimitsTest() {
var nonPrioTimeLimitsResponse = httpRequest("/limits/session-time-limit",
LimitsController.SessionTimeLimitResponse.class);
assertNotNull(nonPrioTimeLimitsResponse);
assertEquals(LimitsController.SessionTimeLimitResponse.INSTANCE, nonPrioTimeLimitsResponse);
}

@Test
public void playtimeApiTest() {
var playtimeResponse = httpRequest("/playtime?playerName={playerName}",
Expand Down

0 comments on commit a04c717

Please sign in to comment.