Azərbaycan dili Bahasa Indonesia Bosanski Català Čeština Dansk Deutsch Eesti English Español Français Galego Hrvatski Italiano Latviešu Lietuvių Magyar Malti Mакедонски Nederlands Norsk Polski Português Português BR Românã Slovenčina Srpski Suomi Svenska Tiếng Việt Türkçe Ελληνικά Български Русский Українська Հայերեն ქართული ენა 中文
Subpage under development, new version coming soon!

Thema: »news XML Data Improvements

2023-12-09 17:08:12
I didn't know where to post, but as this is a devs' corner...

On a given date, is there any way of finding the week and season of Sokker?
2023-12-09 17:21:58
If you mean current season / week then in https://sokker.org/api/current, under "today".

If you want to get it for any date then I think you need to write a function that will calculate it.
2023-12-09 17:32:45
it is the function, and it was my question.

I break my head trying to write this function.

I can take a reference date : week 1 season x then calculate nb of weeks diff to a given date. And found the w with a modulo : week_diff mod 13

But since the number of weeks could be different for different years and sokker week start on (saturday?) it doesn't match.
(Edith war hier)
2023-12-09 18:05:12
Probably there's an easiest way but...

You can get the opposite, I mean, you can get the date of every Sokker week since week 0 to the current one, and store the info in a table so you can access the info that you want

For example, with this:

https://sokker.org/api/training?filter[week]=0

You can see the date was 2003-07-10
2023-12-09 18:13:39
I use this function to calculate the season week given a week number:


public final static int JORNADA_NUEVO_SISTEMA_LIGAS = 976;
public final static int JORNADAS_TEMPORADA = 13;

public static int getJornadaMod(int jornada) {
// NOTA: a partir de la jornada 976 las temporadas pasan a ser de 13 semanas
return jornada < JORNADA_NUEVO_SISTEMA_LIGAS ? jornada % 16 : (jornada - JORNADA_NUEVO_SISTEMA_LIGAS) % JORNADAS_TEMPORADA;
}
(Edith war hier)
2023-12-09 18:18:13
Smart ;-)

But that's a huge table to load just to find a sokker week/season ^^
2023-12-09 18:23:31
Thanks Terrion. The "hard" table seems to be the only reliable way :-/
2023-12-09 19:05:58
interesting, date are calculated :
https://sokker.org/api/training?filter[week]=1100 ( futur date).

So there's a function to calculate this.
2023-12-09 19:17:00
That about counting days between dates seems a good way
(Edith war hier)
2023-12-10 11:49:22
Sure, but didn't work for me. At least, its not 100% reliable, sometimes i ve got a shift in week (probably : weeks start on Saturday(?) on sokker, days/weeks are not the same for each years...).

There is also one other problem : age update are made on friday (as far as i remember) week "13" which should be considered as week 0
2023-12-10 12:26:02
This is for yesterday, which was week 1066:

SELECT DATEDIFF('20231209', '20030705') / 7
= 1066.0000

And this is for Friday, which was week 1065:

SELECT DATEDIFF('20231208', '20030705') / 7
= 1065.8571
(Edith war hier)
2023-12-10 12:59:07
I do it like this:

Take '2022-03-19' as a base date, that's the first day of the first 13-week season (season 61, week 1, day 0 - weeks are counted from 1-13, but days are counted from 0-6, where 0 is Saturday), then get difference in days between this date and some later date you want, then do some math to get season, week and day as shown on screenshot.


As you can see in console it calculates 2023-12-09 (yesterday) as the first day of 13th week of the current season, so it's working correctly.

There might be some problems with this - if you insert data on current time and you don't know if sokker update already happened on that day, for example like you said about age update on Friday - you wouldn't know if age update already happened or not. I suggest to insert data with season / week / day to your database and to use values from /api/current. And treat the case of the last Friday in some special way (for example do -1 to age if week == 13 and day == 6 to make it consistent with season number).

I collect transfers once a day, always after the sokker update. I insert transfers based on the ending date, so I need to treat specially transfers that I collect on season's last Thursday that will end on season's first Saturday (in this case I manually add +1 to age).
2023-12-10 15:50:56
That’s what i was doing, but divise by weeks not by days, certainly the rest of division (of weeks) cause me some shifts. Or maybe date obj in php is not the same when calculating diff.
Good catch for day=6 and age update !

Thanks guys !
2024-02-04 12:53:17
Hello guys,

I saw that there was an api/transfer (https://sokker.org/api/transfer)
Do you know if it can be used with filters to browse and get a list of transfers?

Something like https://sokker.org/api/transfer?[country]=1 ...
2024-02-04 13:33:43
it can

you can just check request sent on transfers page to get some of the possible filters, but there seems to be no possibility to filter by country (other than filter results after search)

iirc, Geston and Mikoos use that API on their page to populate their db with data from sokker, you can ask them for more info
2024-02-04 13:50:42
I don't think you can filter by country

However, you can easily get all the transfers quickly, I do it in a loop:

https://sokker.org/api/transfer?filter[limit]=200&filter[offset]=X
with X starting at 0 and then X += 195 until you get 0 transfers in response, then I remove all the duplicates from the list where I store them, and after that I put new ones in db.

I change offset by less than 200 to be sure that I won't miss any transfers (they change positions when other transfers finish / new transfers appear)