Skip to content

Commit 06adde8

Browse files
elegantShock2258bhoopesh369killerninjacatshubham-1806
authored
Feat: Stats and Tutorials (#3)
* feat: stats * feat: tutorials (#2) * feat: tutorials * fix: update games * fix: stats errors, pvpleaderboard stats --------- Co-authored-by: shubham-1806 <[email protected]> Co-authored-by: Bhoopesh <[email protected]> --------- Co-authored-by: Bhoopesh <[email protected]> Co-authored-by: Nithin Balan <[email protected]> Co-authored-by: shubham-1806 <[email protected]>
1 parent e68376a commit 06adde8

40 files changed

+1454
-52
lines changed

docs/spec/CodeCharacter-API.yml

Lines changed: 194 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ paths:
699699
college: NITT
700700
avatarId: 1
701701
tutorialLevel: 2
702+
codeTutorialLevel: 3
702703
tier: TIER1
703704
isProfileComplete: true
704705
isTutorialComplete: true
@@ -1099,7 +1100,7 @@ paths:
10991100
responses:
11001101
200:
11011102
description: OK
1102-
headers: { }
1103+
headers: {}
11031104
content:
11041105
application/json:
11051106
schema:
@@ -1493,7 +1494,7 @@ paths:
14931494
description: Created
14941495
'400':
14951496
description: Bad Request
1496-
headers: { }
1497+
headers: {}
14971498
content:
14981499
application/json:
14991500
schema:
@@ -1513,11 +1514,11 @@ paths:
15131514
examples:
15141515
CodeExample:
15151516
value:
1516-
value : "#include<iostream>"
1517+
value: '#include<iostream>'
15171518
language: CPP
15181519
MapExample:
15191520
value:
1520-
value: "[[0,0,0]]"
1521+
value: '[[0,0,0]]'
15211522
tags:
15221523
- Daily Challenges
15231524
/dc/matches:
@@ -1570,8 +1571,113 @@ paths:
15701571
description: Size of the page
15711572
parameters: []
15721573

1574+
'/stats/':
1575+
get:
1576+
summary: Get all General Stats for current user and top user
1577+
tags:
1578+
- stats
1579+
responses:
1580+
'200':
1581+
description: OK
1582+
content:
1583+
application/json:
1584+
schema:
1585+
type: array
1586+
items:
1587+
$ref: '#/components/schemas/UserMatchStats'
1588+
operationId: getStats
1589+
description: Gets all statistics for the current user
1590+
parameters: []
1591+
1592+
1593+
'/codetutorial/get/{codeTutorialNumber}':
1594+
get:
1595+
summary: Get tutorial by number
1596+
description: Get a single tutorial
1597+
operationId: getCodeTutorialByNumber
1598+
parameters:
1599+
- name: codeTutorialNumber
1600+
in: path
1601+
required: true
1602+
schema:
1603+
type: integer
1604+
responses:
1605+
200:
1606+
description: OK
1607+
content:
1608+
application/json:
1609+
schema:
1610+
$ref: '#/components/schemas/TutorialsGetRequest'
1611+
401:
1612+
description: Unauthorized
1613+
403:
1614+
description: Forbidden
1615+
404:
1616+
description: Not found
1617+
tags:
1618+
- Tutorials
1619+
1620+
/codetutorial/submit:
1621+
post:
1622+
summary: Match Execution for Tutorials
1623+
description: Match making for Tutorials
1624+
operationId: createCodeTutorialMatch
1625+
responses:
1626+
'201':
1627+
description: Created
1628+
'400':
1629+
description: Bad Request
1630+
headers: { }
1631+
content:
1632+
application/json:
1633+
schema:
1634+
$ref: '#/components/schemas/GenericError'
1635+
examples:
1636+
Example:
1637+
value:
1638+
message: Some field missing
1639+
'401':
1640+
description: Unauthorized
1641+
requestBody:
1642+
required: true
1643+
content:
1644+
application/json:
1645+
schema:
1646+
$ref: '#/components/schemas/CodeTutorialMatchRequest'
1647+
examples:
1648+
CodeExample:
1649+
value:
1650+
value : "#include<iostream>"
1651+
language: CPP
1652+
codeTutorialNumber: 2
1653+
MapExample:
1654+
value:
1655+
value: "[[0,0,0]]"
1656+
codeTutorialNumber: 6
1657+
tags:
1658+
- Tutorials
1659+
1660+
15731661
components:
15741662
schemas:
1663+
UserMatchStats:
1664+
title: UserMatchStats
1665+
type: object
1666+
description: User Match Stats model
1667+
properties:
1668+
avgAtk:
1669+
type: number
1670+
default: 0
1671+
dc_wins:
1672+
type: number
1673+
default: 0
1674+
coins:
1675+
type: number
1676+
default: 0
1677+
required:
1678+
- avgAtk
1679+
- dc_wins
1680+
- coins
15751681
PasswordLoginRequest:
15761682
title: PasswordLoginRequest
15771683
type: object
@@ -2024,6 +2130,9 @@ components:
20242130
tutorialLevel:
20252131
type: integer
20262132
example: 1
2133+
codeTutorialLevel:
2134+
type: integer
2135+
example: 3
20272136
tier:
20282137
$ref: '#/components/schemas/TierType'
20292138
isProfileComplete:
@@ -2041,6 +2150,7 @@ components:
20412150
- college
20422151
- avatarId
20432152
- tutorialLevel
2153+
- codeTutorialLevel
20442154
- isProfileComplete
20452155
- isTutorialComplete
20462156
UpdateCurrentUserProfile:
@@ -2260,6 +2370,29 @@ components:
22602370
- destruction
22612371
- coinsUsed
22622372
- status
2373+
TutorialGame:
2374+
title: Game
2375+
type: object
2376+
description: Game model
2377+
properties:
2378+
id:
2379+
type: string
2380+
format: uuid
2381+
example: 123e4567-e89b-12d3-a456-426614174000
2382+
destruction:
2383+
type: number
2384+
example: 100
2385+
coinsUsed:
2386+
type: integer
2387+
logs:
2388+
type: string
2389+
status:
2390+
$ref: '#/components/schemas/GameStatus'
2391+
required:
2392+
- id
2393+
- destruction
2394+
- coinsUsed
2395+
- status
22632396
GameLog:
22642397
type: string
22652398
description: Game log model
@@ -2315,6 +2448,46 @@ components:
23152448
required:
23162449
- user
23172450
- stats
2451+
TutorialsGetRequest:
2452+
title: Get tutorials
2453+
description: Get the game tutorials
2454+
type: object
2455+
properties:
2456+
tutorialId:
2457+
type: integer
2458+
example: 1
2459+
tutorialName:
2460+
type: string
2461+
example: Tutorial for Spawning attacker
2462+
tutorialType:
2463+
$ref: '#/components/schemas/ChallengeType'
2464+
description:
2465+
type: string
2466+
example: Brief description of how the code works
2467+
tutorialCodes:
2468+
$ref: '#/components/schemas/TutorialCodeObject'
2469+
required:
2470+
- tutorialId
2471+
- tutorialName
2472+
- tutorialCodes
2473+
2474+
TutorialCodeObject:
2475+
title: Tutorial Code Object
2476+
description: The object containing the code for the tutorial
2477+
type: object
2478+
properties:
2479+
cpp:
2480+
type: string
2481+
example: This would have the cpp code for the tutorial
2482+
java:
2483+
type: string
2484+
example: This would have the java code for the tutorial
2485+
python:
2486+
type: string
2487+
example: This would have the python code for the tutorial
2488+
image:
2489+
type: string
2490+
23182491

23192492
DailyChallengeGetRequest:
23202493
title: Get daily challenge
@@ -2373,14 +2546,30 @@ components:
23732546
title: DailyChallengeMatchRequest
23742547
description: Request Model for the daily challenge
23752548
type: object
2549+
properties:
2550+
value:
2551+
type: string
2552+
example: '#include<iostream>'
2553+
language:
2554+
$ref: '#/components/schemas/Language'
2555+
required:
2556+
- value
2557+
CodeTutorialMatchRequest:
2558+
title: CodeTutorialMatchRequest
2559+
description: Request Model for the tutorial mode
2560+
type: object
23762561
properties:
23772562
value:
23782563
type: string
23792564
example: "#include<iostream>"
23802565
language:
23812566
$ref: '#/components/schemas/Language'
2567+
codeTutorialNumber:
2568+
type: integer
2569+
nullable: false
23822570
required:
23832571
- value
2572+
- codeTutorialNumber
23842573
GenericError:
23852574
title: GenericError
23862575
type: object
@@ -2554,3 +2743,4 @@ tags:
25542743
- name: match
25552744
- name: notification
25562745
- name: user
2746+
- name: stats

library/.openapi-generator/FILES

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ src/main/kotlin/delta/codecharacter/core/MapApi.kt
99
src/main/kotlin/delta/codecharacter/core/MatchApi.kt
1010
src/main/kotlin/delta/codecharacter/core/NotificationApi.kt
1111
src/main/kotlin/delta/codecharacter/core/PvpGameApi.kt
12+
src/main/kotlin/delta/codecharacter/core/StatsApi.kt
13+
src/main/kotlin/delta/codecharacter/core/TutorialsApi.kt
1214
src/main/kotlin/delta/codecharacter/core/UserApi.kt
1315
src/main/kotlin/delta/codecharacter/dtos/ActivateUserRequestDto.kt
1416
src/main/kotlin/delta/codecharacter/dtos/AuthStatusResponseDto.kt
1517
src/main/kotlin/delta/codecharacter/dtos/ChallengeTypeDto.kt
1618
src/main/kotlin/delta/codecharacter/dtos/CodeDto.kt
1719
src/main/kotlin/delta/codecharacter/dtos/CodeRevisionDto.kt
20+
src/main/kotlin/delta/codecharacter/dtos/CodeTutorialMatchRequestDto.kt
1821
src/main/kotlin/delta/codecharacter/dtos/CodeTypeDto.kt
1922
src/main/kotlin/delta/codecharacter/dtos/CompleteProfileRequestDto.kt
2023
src/main/kotlin/delta/codecharacter/dtos/CreateCodeRevisionRequestDto.kt
@@ -50,10 +53,15 @@ src/main/kotlin/delta/codecharacter/dtos/RatingHistoryDto.kt
5053
src/main/kotlin/delta/codecharacter/dtos/RegisterUserRequestDto.kt
5154
src/main/kotlin/delta/codecharacter/dtos/ResetPasswordRequestDto.kt
5255
src/main/kotlin/delta/codecharacter/dtos/TierTypeDto.kt
56+
src/main/kotlin/delta/codecharacter/dtos/TutorialCodeObjectDto.kt
57+
src/main/kotlin/delta/codecharacter/dtos/TutorialGameDto.kt
5358
src/main/kotlin/delta/codecharacter/dtos/TutorialUpdateTypeDto.kt
59+
src/main/kotlin/delta/codecharacter/dtos/TutorialsGetRequestDto.kt
5460
src/main/kotlin/delta/codecharacter/dtos/UpdateCurrentUserProfileDto.kt
5561
src/main/kotlin/delta/codecharacter/dtos/UpdateLatestCodeRequestDto.kt
5662
src/main/kotlin/delta/codecharacter/dtos/UpdateLatestMapRequestDto.kt
5763
src/main/kotlin/delta/codecharacter/dtos/UpdatePasswordRequestDto.kt
64+
src/main/kotlin/delta/codecharacter/dtos/UserMatchStatDto.kt
65+
src/main/kotlin/delta/codecharacter/dtos/UserMatchStatsInnerDto.kt
5866
src/main/kotlin/delta/codecharacter/dtos/UserStatsDto.kt
5967
src/main/kotlin/delta/codecharacter/dtos/VerdictDto.kt
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.1.0).
3+
* https://openapi-generator.tech
4+
* Do not edit the class manually.
5+
*/
6+
package delta.codecharacter.core
7+
8+
import delta.codecharacter.dtos.UserMatchStatsInnerDto
9+
import io.swagger.v3.oas.annotations.*
10+
import io.swagger.v3.oas.annotations.enums.*
11+
import io.swagger.v3.oas.annotations.media.*
12+
import io.swagger.v3.oas.annotations.responses.*
13+
import io.swagger.v3.oas.annotations.security.*
14+
import org.springframework.http.HttpStatus
15+
import org.springframework.http.MediaType
16+
import org.springframework.http.ResponseEntity
17+
18+
import org.springframework.web.bind.annotation.*
19+
import org.springframework.validation.annotation.Validated
20+
import org.springframework.web.context.request.NativeWebRequest
21+
import org.springframework.beans.factory.annotation.Autowired
22+
23+
import jakarta.validation.constraints.DecimalMax
24+
import jakarta.validation.constraints.DecimalMin
25+
import jakarta.validation.constraints.Email
26+
import jakarta.validation.constraints.Max
27+
import jakarta.validation.constraints.Min
28+
import jakarta.validation.constraints.NotNull
29+
import jakarta.validation.constraints.Pattern
30+
import jakarta.validation.constraints.Size
31+
import jakarta.validation.Valid
32+
33+
import kotlin.collections.List
34+
import kotlin.collections.Map
35+
36+
@Validated
37+
@RequestMapping("\${api.base-path:}")
38+
interface StatsApi {
39+
40+
@Operation(
41+
summary = "Get all General Stats for current user and top user",
42+
operationId = "getStats",
43+
description = """Gets all statistics for the current user""",
44+
responses = [
45+
ApiResponse(responseCode = "200", description = "OK", content = [Content(array = ArraySchema(schema = Schema(implementation = UserMatchStatsInnerDto::class)))])
46+
],
47+
security = [ SecurityRequirement(name = "http-bearer") ]
48+
)
49+
@RequestMapping(
50+
method = [RequestMethod.GET],
51+
value = ["/stats/"],
52+
produces = ["application/json"]
53+
)
54+
fun getStats(): ResponseEntity<List<kotlin.collections.List<UserMatchStatsInnerDto>>> {
55+
return ResponseEntity(HttpStatus.NOT_IMPLEMENTED)
56+
}
57+
}

0 commit comments

Comments
 (0)