cmpatino HF Staff commited on
Commit
eac8165
Β·
1 Parent(s): cc39d1d

Change leaderboard parser in mesages

Browse files
Files changed (1) hide show
  1. static/index.html +7 -3
static/index.html CHANGED
@@ -1140,7 +1140,11 @@ const sendMessageTip = document.getElementById('sendMessageTip');
1140
  // PARSING (messages)
1141
  // ─────────────────────────────────────────────────────────────
1142
  const FILENAME_RE = /^(\d{8})-(\d{6})_(.+?)(?:_(.+))?\.md$/;
1143
- const STEPS_RE = /(\d[\d,]*)\s*steps/gi;
 
 
 
 
1144
  const STEPS_MIN = 100;
1145
  const STEPS_MAX = 100000;
1146
 
@@ -1214,8 +1218,8 @@ function epochFromFilename(filename) {
1214
  function findBestSteps(body) {
1215
  const matches = [];
1216
  let m;
1217
- STEPS_RE.lastIndex = 0;
1218
- while ((m = STEPS_RE.exec(body)) !== null) {
1219
  const v = parseInt(m[1].replace(/,/g, ''), 10);
1220
  if (v >= STEPS_MIN && v <= STEPS_MAX) matches.push(v);
1221
  }
 
1140
  // PARSING (messages)
1141
  // ─────────────────────────────────────────────────────────────
1142
  const FILENAME_RE = /^(\d{8})-(\d{6})_(.+?)(?:_(.+))?\.md$/;
1143
+ // Matches the explicit leaderboard-result marker defined in the collab README:
1144
+ // **Leaderboard result:** <steps> steps Β· ...
1145
+ // Captures the step count from the same line as the marker. Loose matches like
1146
+ // "2812 steps" in prose are intentionally ignored.
1147
+ const LEADERBOARD_RESULT_RE = /\*\*\s*leaderboard\s+result\s*:\s*\*\*[^\n]*?(\d[\d,]*)\s*steps/gi;
1148
  const STEPS_MIN = 100;
1149
  const STEPS_MAX = 100000;
1150
 
 
1218
  function findBestSteps(body) {
1219
  const matches = [];
1220
  let m;
1221
+ LEADERBOARD_RESULT_RE.lastIndex = 0;
1222
+ while ((m = LEADERBOARD_RESULT_RE.exec(body)) !== null) {
1223
  const v = parseInt(m[1].replace(/,/g, ''), 10);
1224
  if (v >= STEPS_MIN && v <= STEPS_MAX) matches.push(v);
1225
  }