Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ kterém jsou data o týmech uloženy.
> [!WARNING]
> Data musí být stažena předtím, než spadne FKSDB, jinak se k datům nepůjde
> dostat. Pro je vhodné stáhnout data dopředu a pokud to situace umožní, tak
> je na soutěží jen aktualizovat.
> je na soutěži jen aktualizovat.

### Spuštění
Script najde všechny `.csv` soubory ve složce `in`. Pokud není v této složce
Expand Down
19 changes: 15 additions & 4 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import json
import glob
import base64

from src.teams import Team, getTeamCoefficientAverage, getTeamPoints

Expand All @@ -23,10 +24,7 @@ def download():

print(f"Downloading teams data for event {eventId}")

req = requests.get(
f'https://db.fykos.cz/api/events/{eventId}/teams',
auth=(username, password)
)
req = get_teams(eventId, username, password)

print("Saving")

Expand All @@ -35,6 +33,19 @@ def download():

print("Download complete")

def get_teams(eventId, username, password):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chce přidat možnost vložit lokální JSON, kdyby se vysral server a nešlo to stáhnout

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Teď asi nerozumím, když budeme mít jen lokální json stáhnutý předtím, tak prostě jen nebudeme dělat download a rovnou spustíme skript, ne? Není potřeba přidávat nějakou možnost do kódu

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, jo, jak jsem se díval jen na ten PR, tak jsem si neuvědomil, jak to funguje a že jsem na toto myslel už jsem jsem to vytvářel, takže tam je separo funkce na download.
Takže ok

credentials = f"{username}:{password}".encode("utf-8")
encoded_credentials = base64.b64encode(credentials).decode("utf-8")
headers = {
"Authorization": f"Basic {encoded_credentials}"
}

req = requests.get(
f'https://db.fykos.cz/api/events/{eventId}/teams',
headers=headers
)
return req


def printTeamTable(teams):
titleString = f"│ N │{"Název týmu":32}│{"ID":^5}│Kat.│Body│Poř. glob.|Poř. v kat.|"
Expand Down