Giter Club home page Giter Club logo

kings-league-project's Introduction

👑 Kings League Infojobs Project ⚽️

Esta web sólo está creada para fines educativos. Kosmos Holdings es el dueño de todos los logos de la Kings League. Este proyecto no tiene ánimo de lucro y no se hace responsable del uso que se pueda hacer del mismo.

Deploy API Scrape Kings League Infojobs Website License: MIT

Mockup API Web

⚡ Actividad Reciente

  1. 🎉 Merged PR #38 in midudev/aprendiendo-react
  2. 🎉 Merged PR #37 in midudev/aprendiendo-react
  3. 🎉 Merged PR #64 in midudev/preguntas-entrevista-react
  4. 🎉 Merged PR #67 in midudev/preguntas-entrevista-react
  5. 🎉 Merged PR #4 in midudev/libros-programacion-gratis
Sumario
  1. Descripción del proyecto
  2. Tecnologías usadas
  3. API
  4. Redes sociales
  5. Lighthouse
  6. Estadísticas Acerca del Autor

English

kings league project

Descripción del proyecto

Este proyecto tiene como objetivo crear una API y página web de la Kings League Infojobs con fines educativos.

La API proporciona acceso a datos de equipos, presidentes, entrenadores, goleadores y asistentes de la Kings League, y la página web ofrece información sobre los equipos, resultados y clasificaciones de la liga.

Tecnologías usadas

Para recuperar los datos de la API, usamos Web Scraping, Node.js, Hono y el servicio de hosting de APIs Cloudflare Workers para la construcción y el despliegue.

La página web está desarrollada con el framework Astro y utilizamos el framework CSS Tailwind para estilizar la interfaz de usuario. Además, hemos utilizado la librería Cheerio para realizar Web Scraping y obtener datos de la Kings League Infojobs.

Para probar y validar el funcionamiento de la aplicación, hemos utilizado la librería de pruebas Vitest.

Si quieres ayudarnos, por favor toma un momento para leer el archivo CONTRIBUTING.md. Allí encontrarás información útil sobre cómo contribuír de manera efectiva y cómo seguir nuestras guías de estilo. ¡Esperamos que disfrutes colaborando con nosotros!

API

Dirección: https://api.kingsleague.dev/

Los endpoints disponibles son:

  • GET /leaderboard: Devuelve la clasificación de la Kings League.
  • GET /teams: Devuelve todos los equipos de la Kings League.
  • GET /teams/:id: Devuelve un equipo de la Kings League.
  • GET /teams/:id/player-12: Devuelve un jugador 12 de un equipo de la Kings League.
  • GET /teams/:id/players/:playerId: Devuelve un jugador de un equipo de la Kings League.
  • GET /presidents: Devuelve todos los presidentes de la Kings League.
  • GET /presidents/:id: Devuelve un presidente de un equipo de la Kings League.
  • GET /coaches: Devuelve todos los entrenadores de la Kings League.
  • GET /coaches/:teamId: Devuelve el entrenador de un equipo de la Kings League.
  • GET /top-scorers: Devuelve los goleadores más destacados de la Kings League.
  • GET /top-scorers/:rank: Devuelve el goleador más destacado de acuerdo a su posición en el ranking de la Kings League.
  • GET /top-assists: Devuelve los asistentes más destacados de la Kings League.
  • GET /top-assists/:rank: Devuelve el asistente más destacado de acuerdo a su posición en el ranking de la Kings League.
  • GET /mvp: Devuelve los MVPs de la Kings League.
  • GET /schedule: Devuelve el calendario de partidos de la Kings League y el resultado de los partidos jugados.
  • GET /players-12: Devuelve los jugadores 12 de la Kings League.

Redes Sociales

¡Síguenos en nuestro canal de Twitch para ver cómo avanzamos en el desarrollo del proyecto o síguenos en Youtube para más contenido acerca de desarrollo fullstack!

o únete a la comunidad en Discord

LightHouse

Lighthouse Performance Badge Lighthouse Accessibility Badge Lighthouse Best Practices Badge Lighthouse SEO Badge

Estadísticas Acerca del Autor

 midudev

midudev

kings-league-project's People

Contributors

1fbr avatar afandos-bbm avatar ameth avatar angelalexqc avatar atticus64 avatar cubancodepath avatar damian-zsiros-prog avatar edgarguitarist avatar fasping avatar felixicaza avatar franco14lorenzo avatar genaroibc avatar github-actions[bot] avatar jasarmas avatar jhodadev avatar joemancera avatar jordinodejs avatar josemasf avatar jpaddeo avatar juanortiz9492 avatar kewinbarboza avatar loadko avatar midudev avatar nightmir3 avatar pabl0parra avatar pabman11 avatar pchaparro avatar saitama1899 avatar whoknowsi avatar xjosee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kings-league-project's Issues

Issue with getTeamFrom

I'm in the second video from the kings league project. I followed every step to add presidents data to leaderboard. But it show me this error: TypeError: Cannot destructure property 'presidentId' of 'TEAMS.find(...)' as it is undefined.

index.js from api folder

` import { writeFile, readFile } from 'node:fs/promises'
import path from 'node:path'

const DB_PATH = path.join(process.cwd(), './db/')

function readDBFile (dbName) {
return readFile(${DB_PATH}/${dbName}.json, 'utf-8').then(JSON.parse)
}

export const TEAMS = await readDBFile('teams')
export const PRESIDENTS = await readDBFile('presidents')
export function writeDBFile (dbName, data) {
writeFile(${DB_PATH}/${dbName}.json, JSON.stringify(data, null, 2), 'utf-8')
} `

leaderboard.js
`
import * as cheerio from 'cheerio'
import { TEAMS, PRESIDENTS, writeDBFile } from '../db/index.js'

const URLS = {
leaderboard: 'https://kingsleague.pro/estadisticas/clasificacion/'
}

async function scrape (url) {
const res = await fetch(url)
const html = await res.text()
return cheerio.load(html)
}

async function getLeaderBoard () {
const $ = await scrape(URLS.leaderboard)
const $rows = $('table tbody tr')

const getTeamFrom = ({ name }) => {
const { presidentId, ...restOfTeam } = TEAMS.find(team => team.name === name)
const president = PRESIDENTS.find(president => president.id === presidentId)
return { ...restOfTeam, president }
}

const cleanText = text => text
.replace(/\t|\n|\s:/g, '')
.replace(/.*:/g, ' ')
.trim()

const LEADERBOARD_SELECTORS = {
team: { selector: '.fs-table-text_3', typeOf: 'string' },
wins: { selector: '.fs-table-text_4', typeOf: 'number' },
loses: { selector: '.fs-table-text_5', typeOf: 'number' },
goalsScored: { selector: '.fs-table-text_6', typeOf: 'number' },
goalsConceded: { selector: '.fs-table-text_7', typeOf: 'number' },
cardsYellow: { selector: '.fs-table-text_8', typeOf: 'number' },
cardsRed: { selector: '.fs-table-text_9', typeOf: 'number' }
}

const leaderboardSelectorEntries = Object.entries(LEADERBOARD_SELECTORS)

const leaderboard = []

$rows.each((index, el) => {
const leaderBoardEntries = leaderboardSelectorEntries.map(([key, { selector, typeOf }]) => {
const rawValue = $(el).find(selector).text()
const cleanedValue = cleanText(rawValue)
const value = typeOf === 'number' ? Number(cleanedValue) : cleanedValue
return [key, value]
})

const { team: teamName, ...leaderboardForTeam } = Object.fromEntries(leaderBoardEntries)

const team = getTeamFrom({ name: teamName })

leaderboardForTeam.teamId = getTeamFrom(leaderboardForTeam)

leaderboard.push({
  ...leaderboardForTeam,
  team
})

})

return leaderboard
}

const leaderboard = await getLeaderBoard()

await writeDBFile('leaderboard', leaderboard)

`

Fix "ranking" key on top_score.json

The top_scorer.js scrapper doesn't delete the selector ranking and creates a duplicate key in the final object like this.

    {
      "ranking": 1
      "playerName": "R. Carbó",
      "gamesPlayed": 1,
      "goals": 3,
      "rank": 1,
      "team": "Saiyans FC",
      "image": "https://kings-league-api.bjvalmaseda.workers.dev/static/logos/saiyans-fc.svg"
    },

This object must have only a rank or ranking key eg.

    {
      "ranking": 1,
      "playerName": "R. Carbó",
      "gamesPlayed": 1,
      "goals": 3,
      "team": "Saiyans FC",
      "image": "https://kings-league-api.bjvalmaseda.workers.dev/static/logos/saiyans-fc.svg"
    },

Some scrappers are broken

I was trying to figure out what was happening with the issue: #240 and I realized that some scrappers are not working. I don't know if that only happen to me

image_2023-01-08_095322710

Jijantes-fc and xbuyer-team broken link

Jijantes-fc link is broken on the schedules tables:

Home page:

/Calendario page:

Probably the reason is the mapping done in the schedule scraper, but the problem is that the logo is named 'jijantes.svg', so, if we change the team name to 'jijantes-fc', the image will broke.

Scrapper improvements

Overview

List of refactors or improvements that can be done to scraping folder.

List

  • Create a function for this piece of code
const rawValue = $el.find(selector).text()
const cleanedValue = cleanText(rawValue)
const value = typeOf === 'number' ? Number(cleanedValue) : cleanedValue

Something like getValueFromElement($, selector, typeOf)

  • Export getImageFromTeam from mvp.js to a util file and use it in scrappers

Others improvements are welcomed.

move test to test folder

Actualmente, nuestros tests se encuentran mezclados con el resto del código fuente en la carpeta raíz del proyecto. Esto puede hacer difícil de rápidamente identificar qué archivos son tests y cuáles no. Además, algunas convenciones de estructuración de proyectos suelen sugerir tener una carpeta específica para los tests.

Por lo tanto, propongo crear una carpeta llamada 'test' y mover todos los archivos de test dentro de ella. Esto debería hacer más fácil mantener una vista general de los tests y seguir las buenas prácticas de estructuración de proyectos.

Por favor, asignen este issue a alguien para que pueda ser abordado.

Budge link to a folk project in the README.md

[![Deploy API](https://github.com/midudev/kings-league-project/actions/workflows/deploy-api.yml/badge.svg?branch=main)](https://github.com/maikCyphlock/kings-league-project/actions/workflows/deploy-api.yml) [![Scrape Kings League Infojobs Website](https://github.com/midudev/kings-league-project/actions/workflows/scrape-kings-league-web.yml/badge.svg?branch=main)](https://github.com/maikCyphlock/kings-league-project/actions/workflows/scrape-kings-league-web.yml)

Issues with page display on iPad.

E9091B92-F07F-4FA0-A0AC-1F0599CC9239

Some of the images do not load well, and as I saw in the 6h live, a solution had been put to the alignment of the names in the table.

Image of team member 'B. juarez' is not displaying in 'Pio FC' team page

Reproducing the problem

If we go inside the team profile route:
https://kingsleague.dev/team/pio-fc/

We can see that the image of B. Juarez is not displaying correctly
image

And if we call the API with the players name:

https://api.kingsleague.dev/static/players/pio-fc-b-ju%C3%A1rez.png

We get a JSON response saying:

{"message":"Not Found"}

Details

Doing a normal refresh or CTRL+SHIFT+R refresh to ensure that the cache is clean does not bring the image neither.

If more information is needed or my contribution is lacking in some way, im happy to revisit this issue.
Thank you!

La imagen tapa el menu de navegacion de la pagina de estadisticas

Buenos dias,

He encontrado un pequeñito fallito, y como una imagen vale más que mil palabras, la pongo a continuación:

image

Como se puede ver en la imagen, para ciertos tamaños de pantalla el menú de navegación de la página de estadísticas es tapado por la imagen del jugador, en este caso la del mvp.

Me pongo a ver si lo puedo arreglar 🚀

Un saludo, muchas gracias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.