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: stats #4

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/spec/CodeCharacter-API.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1570,8 +1570,44 @@ paths:
description: Size of the page
parameters: []

'/stats/':
get:
summary: Get all General Stats for current user and top user
tags:
- stats
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/UserMatchStats'
operationId: getStats
description: Gets all statistics for the current user
parameters: []

components:
schemas:
UserMatchStats:
title: UserMatchStats
type: object
description: User Match Stats model
properties:
avgAtk:
type: number
default: 0
dc_wins:
type: number
default: 0
coins:
type: number
default: 0
required:
- avgAtk
- dc_wins
- coins
PasswordLoginRequest:
title: PasswordLoginRequest
type: object
Expand Down Expand Up @@ -2554,3 +2590,4 @@ tags:
- name: match
- name: notification
- name: user
- name: stats
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"react-router-dom": "^6.6.1",
"react-split-pane": "^0.1.92",
"react-vertical-timeline-component": "^3.6.0",
"recharts": "^2.10.3",
"redux": "^4.2.0",
"redux-persist": "^6.0.0",
"vscode-ws-jsonrpc": "^2.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/client/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ src/apis/MapApi.ts
src/apis/MatchApi.ts
src/apis/NotificationApi.ts
src/apis/PvpGameApi.ts
src/apis/StatsApi.ts
src/apis/UserApi.ts
src/apis/index.ts
src/index.ts
Expand Down
91 changes: 91 additions & 0 deletions packages/client/src/apis/StatsApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* tslint:disable */
/* eslint-disable */
/**
* CodeCharacter API
* Specification of the CodeCharacter API
*
* The version of the OpenAPI document: 2023.0.1
* Contact: delta@nitt.edu
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import * as runtime from '../runtime';
import type { UserMatchStats } from '../models';

/**
* StatsApi - interface
*
* @export
* @interface StatsApiInterface
*/
export interface StatsApiInterface {
/**
* Gets all statistics for the current user
* @summary Get all General Stats for current user and top user
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof StatsApiInterface
*/
getStatsRaw(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<Array<UserMatchStats>>>;

/**
* Gets all statistics for the current user
* Get all General Stats for current user and top user
*/
getStats(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<UserMatchStats>>;
}

/**
*
*/
export class StatsApi extends runtime.BaseAPI implements StatsApiInterface {
/**
* Gets all statistics for the current user
* Get all General Stats for current user and top user
*/
async getStatsRaw(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<runtime.ApiResponse<Array<UserMatchStats>>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token('http-bearer', []);

if (tokenString) {
headerParameters['Authorization'] = `Bearer ${tokenString}`;
}
}
const response = await this.request(
{
path: `/stats/`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
},
initOverrides,
);

return new runtime.JSONApiResponse(response);
}

/**
* Gets all statistics for the current user
* Get all General Stats for current user and top user
*/
async getStats(
initOverrides?: RequestInit | runtime.InitOverrideFunction,
): Promise<Array<UserMatchStats>> {
const response = await this.getStatsRaw(initOverrides);
return await response.value();
}
}
1 change: 1 addition & 0 deletions packages/client/src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export * from './MapApi';
export * from './MatchApi';
export * from './NotificationApi';
export * from './PvpGameApi';
export * from './StatsApi';
export * from './UserApi';
25 changes: 25 additions & 0 deletions packages/client/src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,31 @@ export interface UpdatePasswordRequest {
*/
passwordConfirmation: string;
}
/**
* User Match Stats model
* @export
* @interface UserMatchStats
*/
export interface UserMatchStats {
/**
*
* @type {number}
* @memberof UserMatchStats
*/
avgAtk: number;
/**
*
* @type {number}
* @memberof UserMatchStats
*/
dcWins: number;
/**
*
* @type {number}
* @memberof UserMatchStats
*/
coins: number;
}
/**
* User stats model
* @export
Expand Down
3 changes: 2 additions & 1 deletion src/AllRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const IncompleteProfile = lazy(
import('./components/Auth/Auth/Login/IncompleteProfile/incompeleteProfile'),
);
const Profile = lazy(() => import('./components/Profile/Profile'));

const Statistics = lazy(() => import('./pages/Statistics/Statistics'));
export default function AllRoutes(): JSX.Element {
const dispatch = useAppDispatch();
const logIn = useAppSelector(isloggedIn);
Expand All @@ -46,6 +46,7 @@ export default function AllRoutes(): JSX.Element {
<Routes>
<Route path="/" element={<Home />} />
<Route path="/dashboard" element={<Dashboard />} />
<Route path="/statistics" element={<Statistics />} />
<Route path="/mapdesigner" element={<MapDesignerPage />} />
<Route path="/history" element={<CommitHistoryPage />} />
<Route path="/leaderboard" element={<LeaderBoardPage />} />
Expand Down
22 changes: 22 additions & 0 deletions src/assets/statistics.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/components/GraphFooter/GraphSelector.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.title {
border: 1px solid #ffffff50 !important;
border-radius: 10px;
background: #ffffff05 !important;
font-size: 1rem;
box-shadow: none !important;
font-family: monospace !important;
align-self: end;
}

.footer {
background-color: #10101080 !important;
backdrop-filter: blur(30px);
color: white;
font-size: 3rem;
text-align: center;
border: 1px solid #ffffff50 !important;
font-family: monospace !important;
}

.button:hover {
background-color: transparent !important;
color: #ffffffa0;
}

.button {
color: white;
text-align: center;
font-size: 1rem;
}
31 changes: 31 additions & 0 deletions src/components/GraphFooter/GraphSelector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ButtonGroup, Dropdown } from 'react-bootstrap';
import styles from './GraphSelector.module.css';
import DropdownMenu from 'react-bootstrap/esm/DropdownMenu';
const GraphSelecter = ({ graph, selected, setSelected }: GraphFooterProps) => {
return (
<div>
<Dropdown as={ButtonGroup} drop="down-centered">
<Dropdown.Toggle className={styles.title}>
{graph[selected]}
</Dropdown.Toggle>
<DropdownMenu className={styles.footer}>
{[...graph].map((g, i) => {
return (
<Dropdown.Item
key={g}
value={i}
className={styles.button}
onClick={() => {
setSelected(i);
}}
>
{g}
</Dropdown.Item>
);
})}
</DropdownMenu>
</Dropdown>
</div>
);
};
export default GraphSelecter;
5 changes: 5 additions & 0 deletions src/components/GraphFooter/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type GraphFooterProps = {
graph: string[];
selected: number;
setSelected: React.Dispatch<React.SetStateAction<number>>;
};
13 changes: 13 additions & 0 deletions src/components/GraphToolTips/GraphToolTip.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.barChartToolTip {
background-color: #1a1a1aca;
backdrop-filter: blur(4rem);
color: white;
font-family: monospace;
font-size: 1rem;
font-weight: 900;
padding: 10px 10px 0px;
border-radius: 5px;
display: flex;
justify-content: center;
align-items: center;
}
Loading
Loading