-
Notifications
You must be signed in to change notification settings - Fork 48
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
Package sports #165
base: main
Are you sure you want to change the base?
Package sports #165
Conversation
- start implementation of standings tab
classify type of queries (team or league)
- improve api calls
improve load script
packages/sports/index.js
Outdated
///////////////////////////////////////////////////// | ||
|
||
if (this.objQuery.type === 'team') { | ||
const findNextFixtures = await axios.get(urlFixtures + `&team=${this.objQuery.id}&next=3`, { headers }).catch(error => ({ error })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a few API call here. Can we reduce the number of calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to find a solution. Maybe get the games between two dates (2 months before and after today) and then sort by today closest ones.
packages/sports/index.js
Outdated
const findLastFixtures = await axios.get(urlFixtures + `&team=${this.objQuery.id}&last=3`, { headers }).catch(error => ({ error })); | ||
Array.prototype.push.apply(fixtures, findLastFixtures.data.response); | ||
|
||
const findStandingsLeague = await axios.get(urlStandings + `&team=${this.objQuery.id}`, { headers }).catch(error => ({ error })); | ||
const league = findStandingsLeague.data.response.filter(s => s.league.country === this.objQuery.country)[0]; | ||
|
||
const findStandings = await axios.get(urlStandings + `&league=${league.league.id}`, { headers }).catch(error => ({ error })); | ||
var standings = findStandings.data.response[0].league.standings[0]; | ||
} | ||
|
||
if (this.objQuery.type === 'league') { | ||
const findCurrentRound = await axios.get(urlCurrentRound + `&league=${this.objQuery.id}¤t=true`, { headers }).catch(error => ({ error })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/sports/index.js
Outdated
this.objQuery = team[0]; | ||
this.objQuery['type'] = 'team'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't really pass the data like this. The trigger function should return true/false. So we need to move the objQuery
logic to sports()
function
- create an array of possible query search types
Great job @johny-mdl! Found a few small issues
|
You can search for Juventus because I ran the loadData.js script for the UEFA Champions League and Juventus is there. The ones you dont see the logo image are teams that are not in the UEFA Champions League, they are in the Italian Serie A league. If we look to the loadData.js script in the beginning I have there: const leaguesIdArray = [94, 39, 140, 2, 5];. These are the leagues I imported and Italian SerieA league is not there. So we need to go to the allLeagues.json and find the ID for that league, include in the array and run the loadData.js script. After that everything will be fine. I did this way because we have a lot of leagues and we must choose the ones we want to include. Over time we can include more leagues with the script. About the support for queries we can search with include instead of equals. I just choose that way because with includes it can give multiple matches and then we must have a logic to choose the right one or simply return false in those cases. |
Hello @jejopl. Regarding my last comment do you need something else from my side? |
Hey @johny-mdl, sorry I was pretty busy lately. Need to test your latest changes. I'll try to do it ASAP and I will get back to you. |
@johny-mdl I've added some small changes, can you take a look and see if it's okay? Thanks |
After starting the application with your changes I see we have this layout: I'm ok with whatever layout you think its better but it seems not pretty in my opinion not having outer borders for the table. So the change for me is changing from boarder-top to boarder in "#presearchSportPackage .games" and ".dark #presearchSportPackage .games". |
I pushed the changes I mention before. Please check if everything is ok :) |
Thanks @johny-mdl. I'll review it when I will have a moment |
The API used is https://www.api-football.com/documentation-v3
Features
Load data
To load static data from the sports API we must run with node the script loadData.js. The script will create two files: teams.json and leagues.json. The array present in the file (leaguesIdArray) represents the ids of the leagues to import. The two json files will be used in the package trigger function, avoiding that every search calls the sports API.
We must add the API key In the script file.
Next steps