Skip to content

Commit

Permalink
Changes made for table backend
Browse files Browse the repository at this point in the history
  • Loading branch information
EmoruwaTolu committed Apr 15, 2024
1 parent f7616a2 commit 5b547f0
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 11 deletions.
3 changes: 2 additions & 1 deletion prem-data/src/components/home-layer-1/pl-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export default function BasicTabs() {

const [data, setData] = useState([]);
const [view, setView] = useState(0);
const [season, setSeason] = useState("2022-23")

const fetchData = async () => {

try{
const response = await fetch(`https://pl-database-1gr2.onrender.com/seasonInformation`);
const response = await fetch(`https://pl-database-1gr2.onrender.com/seasonInformation/${season}`);
const data = await response.json();
setData(data);
}
Expand Down
2 changes: 1 addition & 1 deletion prem-data/src/pages/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function Quiz(){
{playerNames.map((player, index) =>
<div
key={index}
className={`word-button ${selectedButtons.includes(player.name) ? 'selected-player' : ''}`}
className={`word-button ${selectedButtons.includes(player.name) ? 'selected-player' : ''} ${isShaking ? 'shake-animation' : ''}`}
onClick={() => handleButtonClick(player)}
>
{player.name}
Expand Down
2 changes: 2 additions & 0 deletions prem-data/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
}
.story-title{
font-size: 1.2em;
color: white;
text-decoration: none;
}
.story-preview{
font-size: 0.9em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Watford
19 4 3 12 17 31 -14 15 0.79 20.3 30.6 -10.3 -0.54
Norwich City
19 3 3 13 12 43 -31 12 0.63 17.2 35.1 -17.8 -0.94
19 2 4 13 11 41 -30 10 0.53 15.1 40.4 -25.3 -1.33
19 2 4 13 11 41 -30 10 0.53 15.1 40.4 -25.3 -1.33
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Burnley
Watford
38 6 5 27 34 77 -43 23 0.61 40.0 64.5 -24.5 -0.64 20,614 Emmanuel Dennis - 10 Ben Foster Relegated
Norwich City
38 5 7 26 23 84 -61 22 0.58 32.3 75.5 -43.2 -1.14 26,836 Teemu Pukki - 11 Tim Krul Relegated
38 5 7 26 23 84 -61 22 0.58 32.3 75.5 -43.2 -1.14 26,836 Teemu Pukki - 11 Tim Krul Relegated
2 changes: 1 addition & 1 deletion server/overallHome.json

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,33 @@ app.get('/blog-posts', async(req,res) => {
}
})

app.get('/seasonInformation', async(req, res) => {
app.get('/seasonInformation/:season', async(req, res) => {
try{
await client.connect()
const season = req.params.season;

const db = client.db(dbName);

const collectionOverall = db.collection('PremierLeagueTeamSeasonsOverall');

const dataOverall = await collectionOverall.find({matchesPlayed: "38"}).toArray();
const dataHome = await collectionOverall.find({location: "Home"}).toArray();
const dataAway = await collectionOverall.find({location: "Away"}).toArray();
const dataOverall = await collectionOverall.find({
$and: [
{season: `PremierLeague${season}Overall`},
{matchesPlayed: "38"}
]
}).toArray();
const dataHome = await collectionOverall.find({
$and: [
{season: `PremierLeague${season}HomeAway`},
{location: "Home"}
]
}).toArray();
const dataAway = await collectionOverall.find({
$and: [
{season: `PremierLeague${season}HomeAway`},
{location: "Away"}
]
}).toArray();

res.json([dataOverall, dataHome, dataAway]);
}
Expand Down
2 changes: 1 addition & 1 deletion server/teamsAway.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/teamsHome.json

Large diffs are not rendered by default.

0 comments on commit 5b547f0

Please sign in to comment.