Codex commited on
Commit ·
e1eb4d1
1
Parent(s): 2744367
Fix Odds API player prop name extraction
Browse files- src/market-scanner.js +27 -1
- test/market-scanner.test.js +4 -3
src/market-scanner.js
CHANGED
|
@@ -441,6 +441,32 @@ function normalizeSide({ marketKey, outcomeName, description, point }) {
|
|
| 441 |
return 'yes';
|
| 442 |
}
|
| 443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
function normalizeLine(point, side, marketKey) {
|
| 445 |
if (point !== null && point !== undefined && point !== '') {
|
| 446 |
const parsed = Number(point);
|
|
@@ -479,7 +505,7 @@ export function normalizeOddsApiEntries(payload = []) {
|
|
| 479 |
continue;
|
| 480 |
}
|
| 481 |
|
| 482 |
-
const playerName =
|
| 483 |
if (!playerName) {
|
| 484 |
continue;
|
| 485 |
}
|
|
|
|
| 441 |
return 'yes';
|
| 442 |
}
|
| 443 |
|
| 444 |
+
function extractOddsApiPlayerName(outcome = {}) {
|
| 445 |
+
const description = normalizeWhitespace(outcome.description);
|
| 446 |
+
const participant = normalizeWhitespace(outcome.participant);
|
| 447 |
+
const playerName = normalizeWhitespace(outcome.player_name);
|
| 448 |
+
const name = normalizeWhitespace(outcome.name);
|
| 449 |
+
const normalizedName = name.toLowerCase();
|
| 450 |
+
|
| 451 |
+
if (description) {
|
| 452 |
+
return description;
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
if (participant) {
|
| 456 |
+
return participant;
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
if (playerName) {
|
| 460 |
+
return playerName;
|
| 461 |
+
}
|
| 462 |
+
|
| 463 |
+
if (['over', 'under', 'yes', 'no'].includes(normalizedName)) {
|
| 464 |
+
return '';
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
return name;
|
| 468 |
+
}
|
| 469 |
+
|
| 470 |
function normalizeLine(point, side, marketKey) {
|
| 471 |
if (point !== null && point !== undefined && point !== '') {
|
| 472 |
const parsed = Number(point);
|
|
|
|
| 505 |
continue;
|
| 506 |
}
|
| 507 |
|
| 508 |
+
const playerName = extractOddsApiPlayerName(outcome);
|
| 509 |
if (!playerName) {
|
| 510 |
continue;
|
| 511 |
}
|
test/market-scanner.test.js
CHANGED
|
@@ -32,7 +32,7 @@ test('normalizes odds api entries into shared market keys', () => {
|
|
| 32 |
{
|
| 33 |
key: 'batter_total_bases',
|
| 34 |
outcomes: [
|
| 35 |
-
{ name: '
|
| 36 |
],
|
| 37 |
},
|
| 38 |
],
|
|
@@ -46,6 +46,7 @@ test('normalizes odds api entries into shared market keys', () => {
|
|
| 46 |
assert.equal(entries[0].side, 'over');
|
| 47 |
assert.equal(entries[0].source, 'odds_api');
|
| 48 |
assert.equal(entries[0].book, 'FanDuel');
|
|
|
|
| 49 |
});
|
| 50 |
|
| 51 |
test('parses circa OCR lines into normalized entries', () => {
|
|
@@ -377,7 +378,7 @@ test('fetches odds api entries from event-level endpoints', async () => {
|
|
| 377 |
{
|
| 378 |
key: 'batter_total_bases',
|
| 379 |
outcomes: [
|
| 380 |
-
{ name: '
|
| 381 |
],
|
| 382 |
},
|
| 383 |
],
|
|
@@ -443,7 +444,7 @@ test('returns partial odds results when later event requests hit 429', async ()
|
|
| 443 |
{
|
| 444 |
key: 'batter_total_bases',
|
| 445 |
outcomes: [
|
| 446 |
-
{ name: '
|
| 447 |
],
|
| 448 |
},
|
| 449 |
],
|
|
|
|
| 32 |
{
|
| 33 |
key: 'batter_total_bases',
|
| 34 |
outcomes: [
|
| 35 |
+
{ name: 'Over', description: 'Aaron Judge', point: 1.5, price: -110 },
|
| 36 |
],
|
| 37 |
},
|
| 38 |
],
|
|
|
|
| 46 |
assert.equal(entries[0].side, 'over');
|
| 47 |
assert.equal(entries[0].source, 'odds_api');
|
| 48 |
assert.equal(entries[0].book, 'FanDuel');
|
| 49 |
+
assert.equal(entries[0].playerName, 'Aaron Judge');
|
| 50 |
});
|
| 51 |
|
| 52 |
test('parses circa OCR lines into normalized entries', () => {
|
|
|
|
| 378 |
{
|
| 379 |
key: 'batter_total_bases',
|
| 380 |
outcomes: [
|
| 381 |
+
{ name: 'Over', description: 'Aaron Judge', point: 1.5, price: -110 },
|
| 382 |
],
|
| 383 |
},
|
| 384 |
],
|
|
|
|
| 444 |
{
|
| 445 |
key: 'batter_total_bases',
|
| 446 |
outcomes: [
|
| 447 |
+
{ name: 'Over', description: 'Aaron Judge', point: 1.5, price: -110 },
|
| 448 |
],
|
| 449 |
},
|
| 450 |
],
|