Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relay stats WIP #15565

Merged
merged 11 commits into from
Jun 23, 2024
Merged

relay stats WIP #15565

merged 11 commits into from
Jun 23, 2024

Conversation

allanjoseph98
Copy link
Member

@allanjoseph98 allanjoseph98 commented Jun 19, 2024

  • All rounds in one (24 hour graph)
  • Peak viewers
  • Fill in the gap when the gap is>1 minute.

@ornicar ornicar self-requested a review June 19, 2024 19:22
@ornicar
Copy link
Collaborator

ornicar commented Jun 19, 2024

image

I can't seem to display viewers, using this dataset:

{ "round": { "id": "uTRtt0cw", "name": "Round 5", "slug": "round-5", "createdAt": 1718451980602, "ongoing": true, "startsAt": 1718802600000 }, "viewers": [ [ 1718800860, 19 ], [ 1718800980, 22 ], [ 1718801040, 21 ], [ 1718801100, 24 ], [ 1718801160, 28 ], [ 1718801220, 27 ], [ 1718801280, 28 ], [ 1718801340, 31 ], [ 1718801460, 29 ], [ 1718801520, 35 ], [ 1718801640, 38 ], [ 1718801700, 36 ], [ 1718801760, 40 ], [ 1718801820, 46 ], [ 1718801880, 44 ], [ 1718801940, 43 ], [ 1718802000, 47 ], [ 1718802060, 49 ], [ 1718802180, 54 ], [ 1718802240, 60 ], [ 1718802300, 61 ], [ 1718802360, 66 ], [ 1718802420, 68 ], [ 1718802480, 76 ], [ 1718802540, 79 ], [ 1718802600, 78 ], [ 1718802660, 81 ], [ 1718802720, 80 ], [ 1718802780, 86 ], [ 1718802840, 90 ], [ 1718802900, 93 ], [ 1718802960, 102 ], [ 1718803020, 106 ], [ 1718803080, 112 ], [ 1718803140, 122 ], [ 1718803260, 124 ], [ 1718803380, 130 ], [ 1718803440, 135 ], [ 1718803500, 139 ], [ 1718803560, 144 ], [ 1718803620, 146 ], [ 1718803680, 144 ], [ 1718803800, 155 ], [ 1718803860, 149 ], [ 1718803920, 153 ], [ 1718803980, 164 ], [ 1718804040, 156 ], [ 1718804100, 161 ], [ 1718804160, 166 ], [ 1718804220, 164 ], [ 1718804280, 161 ], [ 1718804340, 166 ], [ 1718804400, 163 ], [ 1718804460, 161 ], [ 1718804520, 170 ], [ 1718804580, 180 ], [ 1718804640, 177 ], [ 1718804700, 185 ], [ 1718804760, 187 ], [ 1718804820, 180 ], [ 1718804880, 187 ], [ 1718804940, 194 ], [ 1718805000, 184 ], [ 1718805060, 186 ], [ 1718805120, 187 ], [ 1718805180, 186 ], [ 1718805240, 189 ], [ 1718805360, 186 ], [ 1718805420, 197 ], [ 1718805480, 200 ], [ 1718805540, 208 ], [ 1718805600, 197 ], [ 1718805660, 207 ], [ 1718805720, 206 ], [ 1718805780, 201 ], [ 1718805840, 208 ], [ 1718805900, 209 ], [ 1718805960, 208 ], [ 1718806020, 213 ], [ 1718806080, 212 ], [ 1718806140, 214 ], [ 1718806200, 211 ], [ 1718806260, 208 ], [ 1718806320, 213 ], [ 1718806380, 218 ], [ 1718806440, 217 ], [ 1718806500, 223 ], [ 1718806560, 217 ], [ 1718806620, 225 ], [ 1718806680, 221 ], [ 1718806740, 230 ], [ 1718806800, 227 ], [ 1718806860, 229 ], [ 1718806920, 235 ], [ 1718806980, 240 ], [ 1718807040, 234 ], [ 1718807100, 236 ], [ 1718807160, 235 ], [ 1718807280, 238 ], [ 1718807340, 235 ], [ 1718807400, 239 ], [ 1718807520, 236 ], [ 1718807700, 237 ], [ 1718807760, 230 ], [ 1718807820, 229 ], [ 1718807880, 238 ], [ 1718807940, 240 ], [ 1718808060, 248 ], [ 1718808120, 253 ], [ 1718808180, 249 ], [ 1718808240, 250 ], [ 1718808300, 253 ], [ 1718808360, 257 ], [ 1718808420, 263 ], [ 1718808480, 258 ], [ 1718808540, 256 ], [ 1718808600, 268 ], [ 1718808660, 267 ], [ 1718808720, 263 ], [ 1718808780, 270 ], [ 1718808840, 263 ], [ 1718808900, 267 ], [ 1718808960, 269 ], [ 1718809020, 271 ], [ 1718809080, 276 ], [ 1718809200, 270 ], [ 1718809260, 268 ], [ 1718809320, 264 ], [ 1718809380, 267 ], [ 1718809440, 278 ], [ 1718809500, 280 ], [ 1718809560, 273 ], [ 1718809620, 275 ], [ 1718809740, 276 ], [ 1718809800, 281 ], [ 1718809860, 284 ], [ 1718809920, 273 ], [ 1718809980, 275 ], [ 1718810040, 276 ], [ 1718810100, 278 ], [ 1718810160, 286 ], [ 1718810220, 287 ], [ 1718810280, 297 ], [ 1718810340, 302 ], [ 1718810400, 296 ], [ 1718810460, 290 ], [ 1718810520, 285 ], [ 1718810580, 286 ], [ 1718810640, 289 ], [ 1718810700, 287 ], [ 1718810760, 288 ], [ 1718810820, 290 ], [ 1718810880, 297 ], [ 1718810940, 300 ], [ 1718811000, 299 ], [ 1718811060, 298 ], [ 1718811120, 309 ], [ 1718811180, 300 ], [ 1718811240, 301 ], [ 1718811300, 316 ], [ 1718811360, 304 ], [ 1718811480, 301 ], [ 1718811540, 300 ], [ 1718811600, 309 ], [ 1718811660, 308 ], [ 1718811720, 310 ], [ 1718811780, 309 ], [ 1718811840, 320 ], [ 1718811900, 312 ], [ 1718811960, 304 ], [ 1718812020, 301 ], [ 1718812080, 309 ], [ 1718812140, 307 ], [ 1718812200, 320 ], [ 1718812320, 313 ], [ 1718812500, 303 ], [ 1718812560, 318 ], [ 1718812620, 310 ], [ 1718812680, 314 ], [ 1718812740, 312 ], [ 1718812800, 322 ], [ 1718812860, 325 ], [ 1718812920, 321 ], [ 1718812980, 317 ], [ 1718813040, 305 ], [ 1718813100, 311 ], [ 1718813160, 303 ], [ 1718813220, 310 ], [ 1718813280, 308 ], [ 1718813340, 302 ], [ 1718813400, 306 ], [ 1718813460, 314 ], [ 1718813520, 317 ], [ 1718813580, 316 ], [ 1718813640, 326 ], [ 1718813700, 323 ], [ 1718813760, 321 ], [ 1718813880, 318 ], [ 1718813940, 316 ], [ 1718814000, 315 ], [ 1718814060, 320 ], [ 1718814120, 325 ], [ 1718814180, 320 ], [ 1718814240, 313 ], [ 1718814300, 315 ], [ 1718814360, 313 ], [ 1718814420, 311 ], [ 1718814480, 308 ], [ 1718814540, 307 ], [ 1718814600, 305 ], [ 1718814660, 300 ], [ 1718814720, 291 ], [ 1718814780, 294 ], [ 1718814840, 295 ], [ 1718814900, 297 ], [ 1718814960, 303 ], [ 1718815020, 301 ], [ 1718815080, 295 ], [ 1718815140, 297 ], [ 1718815200, 303 ], [ 1718815260, 299 ], [ 1718815320, 298 ], [ 1718815380, 302 ], [ 1718815440, 309 ], [ 1718815500, 301 ], [ 1718815560, 293 ], [ 1718815620, 283 ], [ 1718815680, 284 ], [ 1718815740, 285 ], [ 1718815800, 293 ], [ 1718815860, 297 ], [ 1718815920, 290 ], [ 1718815980, 297 ], [ 1718816040, 291 ], [ 1718816100, 288 ], [ 1718816160, 293 ], [ 1718816220, 292 ], [ 1718816280, 287 ], [ 1718816340, 292 ], [ 1718816400, 288 ], [ 1718816460, 291 ], [ 1718816520, 303 ], [ 1718816580, 299 ], [ 1718816640, 295 ], [ 1718816700, 284 ], [ 1718816820, 292 ], [ 1718816880, 282 ], [ 1718816940, 273 ], [ 1718817000, 269 ], [ 1718817060, 267 ], [ 1718817120, 256 ], [ 1718817180, 249 ], [ 1718817240, 244 ], [ 1718817300, 240 ], [ 1718817360, 232 ], [ 1718817420, 241 ], [ 1718817480, 244 ], [ 1718817540, 241 ], [ 1718817600, 242 ], [ 1718817660, 222 ], [ 1718817780, 221 ], [ 1718817840, 217 ], [ 1718817900, 215 ], [ 1718817960, 220 ], [ 1718818020, 210 ], [ 1718818140, 206 ], [ 1718818200, 212 ], [ 1718818260, 219 ], [ 1718818320, 223 ], [ 1718818380, 228 ], [ 1718818440, 227 ], [ 1718818500, 226 ], [ 1718818620, 230 ], [ 1718818680, 223 ], [ 1718818740, 213 ], [ 1718818800, 210 ], [ 1718818860, 211 ], [ 1718818980, 210 ], [ 1718819040, 214 ], [ 1718819100, 216 ], [ 1718819160, 208 ], [ 1718819220, 211 ], [ 1718819280, 208 ], [ 1718819340, 207 ], [ 1718819400, 209 ], [ 1718819460, 205 ], [ 1718819520, 206 ], [ 1718819580, 205 ], [ 1718819640, 211 ], [ 1718819700, 216 ], [ 1718819820, 223 ], [ 1718819880, 218 ], [ 1718819940, 213 ], [ 1718820000, 207 ], [ 1718820060, 209 ], [ 1718820120, 207 ], [ 1718820180, 199 ], [ 1718820240, 198 ], [ 1718820300, 192 ], [ 1718820360, 199 ], [ 1718820420, 195 ], [ 1718820480, 191 ], [ 1718820660, 188 ], [ 1718820720, 182 ], [ 1718820780, 180 ], [ 1718820840, 176 ], [ 1718820900, 166 ], [ 1718820960, 172 ], [ 1718821020, 170 ], [ 1718821080, 174 ], [ 1718821140, 169 ] ] }

No errors in the console.

@allanjoseph98
Copy link
Member Author

Are you injecting it or is that actually what you have stored in mongo? data should be of type RelayStats. What you've sent is of type RoundStats.

If injecting with what you've sent,

export default function initModule(data: RelayStats) {
  data = { rounds: [yourDataset] };

image

@ornicar
Copy link
Collaborator

ornicar commented Jun 20, 2024

it's from prod mongodb. I do have the full dataset even if I only posted one round here, the one I was trying to display.

image

@ornicar
Copy link
Collaborator

ornicar commented Jun 20, 2024

export default function initModule(data: RelayStats) {
  data = { rounds: data.rounds.slice(4, 5) };

This makes it work, so it's something about the other rounds that makes it fail.

@ornicar
Copy link
Collaborator

ornicar commented Jun 20, 2024

It always select the last round to make the chart. The last round is empty until the tournament is fully over.

const makeChart = (data: RelayStats, $el: Cash) => {
  const last = data.rounds[data.rounds.length - 1];
  const ds = makeDataset(last, $el[0] as HTMLCanvasElement);

@allanjoseph98
Copy link
Member Author

Stupid of me. Will rework

@ornicar ornicar mentioned this pull request Jun 20, 2024
@ornicar
Copy link
Collaborator

ornicar commented Jun 20, 2024

looks like this branch introduces a new lint warning

lila/ui/chart/dist/chart.lag.d.ts
  3:35  warning  'TType' is defined but never used  @typescript-eslint/no-unused-vars

and this doesn't help

declare module 'chart.js' {
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  interface PluginOptionsByType<TType extends ChartType> {

because the warrning is about the generated dist/chart.lag.d.ts.
Nasty stuff.

@ornicar
Copy link
Collaborator

ornicar commented Jun 23, 2024

This is already very useful as is, so I'm going to deploy it tomorrow.

@ornicar ornicar marked this pull request as ready for review June 23, 2024 15:43
@ornicar ornicar merged commit 89bb8dc into lichess-org:master Jun 23, 2024
5 checks passed
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.

None yet

2 participants