Skip to content

Conversation

@julien4215
Copy link
Contributor

@julien4215 julien4215 commented Jun 20, 2025

Close #15130

This more or less working but there are still some questions/issues to be addressed

  • I chose to store the suscriber ids in the fide player collection but it is regularly updated with new fide data so I think it might remove the subscribers.
  • I used NotificationContent.BroadcastRound for the notification but maybe it would be better to create a new NotificationContent if we want to add a new setting to allow to enable separately broadcast round and broadcast player notifications.
  • When a file pgn is used as the source, it seems to call initially the function RelaySync.updateChapter once only for the first board but I would expect this function to be called for each board. Also the tags seems to be missing for this first call. However when new moves are received from the pgn source, the function RelaySync.updateChapter is called as expected with pgn tags

@julien4215 julien4215 force-pushed the fide-player-subscribe branch 4 times, most recently from 641f8e6 to f5d84c0 Compare June 24, 2025 15:55
@julien4215 julien4215 marked this pull request as ready for review June 24, 2025 15:55
@julien4215 julien4215 force-pushed the fide-player-subscribe branch 2 times, most recently from 290147e to 88404b1 Compare June 25, 2025 20:17
when a FIDE player they follow plays a game in a broadcast.
@julien4215 julien4215 force-pushed the fide-player-subscribe branch from 88404b1 to 0ac0ea8 Compare June 25, 2025 20:18
@ornicar
Copy link
Collaborator

ornicar commented Jun 25, 2025

Nice, thanks.

Because most (thousands) users will follow the top 10 players, I think it makes more sense to use a new collection to avoid ending up with a few gigantic player documents.

Here's a relation document that indicates that u1 follows u2:

  { _id: 'thibault/lizen56', u1: 'thibault', u2: 'lizen56', r: true },
  { _id: 'thibault/lizen49', u1: 'thibault', u2: 'lizen49', r: true },
  { _id: 'kinner/thibault', u1: 'kinner', u2: 'thibault', r: true },
  { _id: 'clarkey/thibault', u1: 'clarkey', u2: 'thibault', r: true }

r: true indicates a follow and r: false a block, we wouldn't need that field for this.

@julien4215
Copy link
Contributor Author

Ah I did not think about that. I guess it would have lead to poor performance storing huge array in documents.

I have added the new collection. It also solves the first point in my first comment about overwriting subscribers when updating FIDE data but there are still the two others issues that remains.

julien4215 and others added 9 commits June 26, 2025 16:00
we can skip the `p` field and more importantly the index it would
normally require,
because a regex like `_id: /^1503014\//` uses the _id index efficiently.

https://www.mongodb.com/docs/manual/reference/operator/query/regex/#index-use

We can also use `distinct("_id", ` so that only the index is used
without ever fetching the document.

We still want the `u` field so we can count and list follows by user.
… many db reqs

not directly related to the PR but something I noticed while reviewing
the previous code discarded the first future and returned the second
one.

Discard both instead, we don't need to wait for notifications to process
the chapter. And make the return type explicit

// used only by the relay module for the follow fide players feature
def setNotified(id: StudyChapterId): Funit =
coll(_.update.one($id(id), $addToSet("notified" -> id)).void)
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's the same id that selects the chapter, and is added to its notified set. It doesn't seem useful to have a chapter doc like {_id: 'abcdefgh', notified: ['abcdefgh']}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that's a mistake I made when copying code from tournament subscription.

@julien4215
Copy link
Contributor Author

julien4215 commented Jun 27, 2025

I think we should always send a notification. Would it be fine to use lila.core.fide.GetPlayer (as it may result in a database request) to always get the player name we send in the notification ?

@ornicar
Copy link
Collaborator

ornicar commented Jun 28, 2025

If the FIDE ID is available, then so should be the player name. Lila adds names and ratings based on the FIDE ID when enriching a source: https://github.com/lichess-org/lila/blob/master/modules/relay/src/main/RelayFidePlayerApi.scala#L10-L10

@ornicar ornicar merged commit 856772d into lichess-org:master Jun 28, 2025
6 checks passed
@julien4215 julien4215 deleted the fide-player-subscribe branch July 3, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broadcast: ability to follow players

3 participants