Skip to content

Commit

Permalink
Update for 2024 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertOstermann authored Mar 17, 2024
1 parent 17e5633 commit 1623f38
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .deployment
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[config]
SCM_DO_BUILD_DURING_DEPLOYMENT=true
1 change: 0 additions & 1 deletion .github/workflows/master_mapleriverbasketball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ jobs:
AUTH0_API_CLIENT_ID: ${{ secrets.AUTH0_API_CLIENT_ID }}
AUTH0_API_CLIENT_SECRET: ${{ secrets.AUTH0_API_CLIENT_SECRET }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
ELEPHANT_SQL_API: ${{ secrets.ELEPHANT_SQL_API }}

- name: Upload
uses: actions/upload-artifact@v3
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/pages/shared/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default function Profile() {

const token = useStoreAuthentication((state) => state.token);

const currentYear = (new Date()).getFullYear();

const mutation = useMutation({
mutationFn: () => UserRequests.updateUser(token, updatedUser),
onSuccess: () => {
Expand Down Expand Up @@ -88,7 +90,7 @@ export default function Profile() {
setUpdatedUser(user);

const year = graduationYear ? graduationYear : 0;
if (year !== 0 && (year < 2023 || year > 2032)) {
if (year !== 0 && (year < currentYear - 1 || year > currentYear + 10)) {
setValidGraduationYear(false);
} else {
setValidGraduationYear(true);
Expand Down Expand Up @@ -241,7 +243,7 @@ export default function Profile() {
}
/>
<Form.Control.Feedback type="invalid">
Please enter a value between 2023 and 2032.
Please enter a value between {currentYear - 1} and {currentYear + 10}.
</Form.Control.Feedback>
</Form.Group>
)}
Expand Down
3 changes: 2 additions & 1 deletion server/src/controllers/UserController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export default class UserController {
return;
}

if (graduationYear && graduationYear !== 0 && (graduationYear < 2023 || graduationYear > 2032)) {
const currentYear = (new Date()).getFullYear();
if (graduationYear && graduationYear !== 0 && (graduationYear < currentYear - 1 || graduationYear > currentYear + 10)) {
response.status(400).json("Invalid Graduation Year");
return;
}
Expand Down
19 changes: 0 additions & 19 deletions server/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import axios from "axios";
import express, { Request, Response } from "express";
import path from "path";

Expand Down Expand Up @@ -65,24 +64,6 @@ app.get(
}
);

// This route requests ElephantSQL to create a database backup.
app.get("/api/v1/backup-database", (req: any, res: Response) => {
const data = {
db: "ybqbejar"
};
const config: any = {
auth: {
username: "",
password: process.env.ELEPHANT_SQL_API
},
};
axios.post("https://api.elephantsql.com/api/backup", data, config);
res.json({
message:
"ElephantSQL database backup requested.",
});
});

// Downloads
app.get("/api/v1/download-player-stats", AuthController.jwtCheck, DownloadController.downloadPlayerStats);

Expand Down
Binary file added sql/backups/2024-03-16.sql
Binary file not shown.
8 changes: 5 additions & 3 deletions sql/entries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
CREATE TABLE IF NOT EXISTS entries (
id SERIAL PRIMARY KEY,
auth_id VARCHAR REFERENCES users (auth_id),
activity_type SMALLINT NOT NULL CHECK (activity_type >= 0) REFERENCES activity_types (activity_id),
activity_type SMALLINT NOT NULL CHECK (
activity_type >= 0
) REFERENCES activity_types (activity_id),
activity_date DATE NOT NULL DEFAULT CURRENT_DATE,
activity_duration INTEGER NOT NULL CHECK (activity_duration >= 0),
date_created DATE NOT NULL DEFAULT CURRENT_TIMESTAMP
Expand All @@ -15,7 +17,7 @@ ALTER TABLE entries
ADD date_created DATE NOT NULL DEFAULT CURRENT_TIMESTAMP;

ALTER TABLE entries
ADD constraint entries_activity_type_fkey FOREIGN KEY (activity_type)
ADD CONSTRAINT entries_activity_type_fkey FOREIGN KEY (activity_type)
REFERENCES activity_types (activity_id);

-- Insert into the entries table
Expand All @@ -37,7 +39,7 @@ SELECT
users.first_name,
users.last_name
FROM entries
LEFT JOIN users ON users.auth_id = entries.auth_id
LEFT JOIN users ON entries.auth_id = users.auth_id
ORDER BY entries.auth_id ASC,
entries.activity_date DESC,
entries.activity_duration DESC;

0 comments on commit 1623f38

Please sign in to comment.