Mismatch between API and chess.com club member count (SOLVED)

Sort:
stephen_33

"Try adding all_time, monthly and weekly together" - I haven't needed to use the club endpoint yet but what's the distinction between these different sets of members?

When I use the Manage Members facility as an admin in one of my groups, I don't see the same headings, members are  simply members.

skelos

Supposedly, activity.

But the definition of activity seems pretty odd to me. Playing in a team match (even registering for one, I think) doesn't count. So a quiet member who doesn't read a group's forums or notes, or post in them, but joins matches when they get a PM can (I think) get stuck in "all_time".

I'm really more interested in when someone last played in a match or posted and/or voted in a team match game. People who do those things but don't post or look at the team's main notes page are common in my experience.

I simply jam all members together and if I want to know when someone was last online, that's their profile. The last time they played one of our matches? That's painful unless the matches are cached and you have player_id for everyone to sort out name changes. (I don't have all this stuff; one day, I hope.)

Vote chess? No endpoints. I hope that's "No endpoints, yet" but we'll see.

stephen_33

Thanks Giles. I agree about it being an odd distinction to make. I have quite a few members in my national team that never contribute anything. I have a lot more that don't comment in notes or forum posts but consistently support us in WL/EL matches.

It would be really useful if I could obtain lists of both types but it seems that isn't possible (from the club endpoint at least) for now.

stephen_33

It begins to raise the question of for whose benefit & utility are these api endpoints created? If a developer came to me & asked what information would be most useful, I think the endpoint structure would look quite different - how about you?

skelos

API design is hard, and will be somewhat constrained by the backend systems and processes in place.

I quite like the idea of activity levels in a club: it's the definition of those levels I find unhelpful.

Sometimes I have to touch more endpoints than I'd prefer to; last_online time is in the profile, ratings data is in statistics, and group memberships are a third endpoint.

On the website the pop-ups show immediately the last_online time and a rating. The profile page shows more rating data and some group membership information.

I imagine that profile pages are built from about three sources: profile, statistics and club memberships plus notes and games. happy.png

This topic is drifting a bit; perhaps a new forum thread would be appropriate, but my preference would be to continue to build out the current design (vote chess!) rather than try to tweak or redesign the current API very much.

The one change I wanted which was slipped in nicely in a backward compatible fashion was to be able to get names in mixed case as the account owner chose, e.g. @NichtGut which is easier to read and remember than @nichtgut (IMHO) and some of the longer names are very much nicer in mixed case.

NichtGut

Forgot to actually gather the average rating for the club. Its running right now, at least the Array lengths when put together do give me the expected 1055 member  count.  Now I just have to wait for my beautiful creation to go trough 1055 JSON endpoints, I will go eat something in the meantime haha.

NichtGut

Took 6 minutes. Average rating is 1639 according to Java. Was that picture old or did it fluctuate like that in a day or is my method wrong?

skelos

 Current figure showing is still 1606, but there will be caching involved.

30 points seems to me a lot for a team with >1000 members.

Too late tonight, but I'll see what I can code up tomorrow to give you a cross-check.

NichtGut

"Hello darkness my old friend..." sad.png

Thanks lol, will wait for the crosscheck.

skelos
$ /usr/bin/time ./club-av-rating asger-s-great-viking-warriors
asger-s-great-viking-warriors
total members:                          1055
members with ratings:                   1054
members without ratings:                1
members returning errors:               0
average rating of members with ratings: 1606

      560.60 real         4.12 user         0.22 sys
skelos

I was accessing other data at the same time, but that took more than five minutes.

At the time of posting, the website agrees 1055 members and an average rating of 1606.

BTW this confirms that the rating shown is for chess_daily (standard chess, daily time control) as that's what I calculated.

NichtGut

Took 5:50 minutes for me. Ill review the code and make it print out important information. I calculate the average rating of everyone, so I divided it by 1055. If the player has no rating his rating passes as "0". Still if I add a "0" and increase the number its divided by the average should be smaller. 

skelos

Mine ran much faster on a group with one member. happy.png

NichtGut

LOL. I am actually testing it right now first with this club haha

https://www.chess.com/club/english-attack-study-group

NichtGut

It does return 1715 which is the rating of that lone member. The way I am calculating this is by getting three separate averages.

 

One average for the weekly members, one for the monthly and one for the all_time members, I then add them up and divide it by 3. In this case since there is just one member my program did not like dividing by 0 lol.

skelos

I don't think that's right ... not all groups have even numbers, so aren't you weighting the smallest group unduly?

I added up each rating I found and divided by the total number of ratings found. I know that's right, although maths was never my strongest subject.

skelos

By "group" there I mean the members who turn up in "weekly" vs those in "monthly" vs those in "all_time".

NichtGut

I dont know what you mean by unduly. There was an issue with small clubs, like the one with just one member for example where there are no players in two of the groups.  For example in my test club:
https://www.chess.com/club/english-attack-study-group

 

My method adds up average ratings of weekly, monthly and all_time groups and then divides it by 3. Clearly does not work because there is not even an average for weekly or monthly since my only member is on the all_time group.

 

To fix this I added a counter variable. It  starts at 0 and grows by one every time a group has one or more members. In my test club there is only one group with one or more players so counter is set to 1. 

 

Then I add the averages 0 + 0 + 1715 and divide it by 1

 

In short, it worked with this test subject. Time to test it out with bigger groups.

 

skelos

10 weekly members each rated 2200. (Strong group!)

20 monthly members each rated 1800.

40 all_time members each rated 1200.

 

(40 * 1200) + (20 * 1800) + (10 * 2200) = 106000

106000 / 70 = 1514

That's the right answer.

 

(2200 + 1800 + 1200) / 3 = 1733, which is wrong: the ten 2200 rated players are over-represented by that calculation.

I can't write a proof, but I hope the example explains why it has to be total rating / total members (give or take anyone without a rating).

Cheers!

NichtGut

Yeah, I was coming to that realization. I corrected it. Now its giving the actual results. I dont know why I over complicated it so much since the beginning.