Codex commited on
Commit ·
d45b158
1
Parent(s): 79419fd
Tighten live-game movement alert filter
Browse files- src/market-scanner.js +12 -6
- test/market-scanner.test.js +2 -2
src/market-scanner.js
CHANGED
|
@@ -1148,20 +1148,26 @@ function getEntryCommenceTime(entry) {
|
|
| 1148 |
}
|
| 1149 |
|
| 1150 |
function isPregameEntry(entry, now = new Date()) {
|
| 1151 |
-
if (entry?.source === 'circa') {
|
| 1152 |
-
return true;
|
| 1153 |
-
}
|
| 1154 |
-
|
| 1155 |
const commenceTime = getEntryCommenceTime(entry);
|
| 1156 |
if (!commenceTime) {
|
| 1157 |
-
return
|
| 1158 |
}
|
| 1159 |
|
| 1160 |
return commenceTime.getTime() > now.getTime();
|
| 1161 |
}
|
| 1162 |
|
| 1163 |
function isPregameSharpRow(row, now = new Date()) {
|
| 1164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1165 |
}
|
| 1166 |
|
| 1167 |
function extractStrikeoutLaneEntriesFromSnippet(text, section) {
|
|
|
|
| 1148 |
}
|
| 1149 |
|
| 1150 |
function isPregameEntry(entry, now = new Date()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1151 |
const commenceTime = getEntryCommenceTime(entry);
|
| 1152 |
if (!commenceTime) {
|
| 1153 |
+
return entry?.source !== 'circa';
|
| 1154 |
}
|
| 1155 |
|
| 1156 |
return commenceTime.getTime() > now.getTime();
|
| 1157 |
}
|
| 1158 |
|
| 1159 |
function isPregameSharpRow(row, now = new Date()) {
|
| 1160 |
+
const rowCommenceTime = getEntryCommenceTime(row);
|
| 1161 |
+
if (rowCommenceTime) {
|
| 1162 |
+
return rowCommenceTime.getTime() > now.getTime();
|
| 1163 |
+
}
|
| 1164 |
+
|
| 1165 |
+
const timedEntries = row?.entries?.filter((entry) => getEntryCommenceTime(entry));
|
| 1166 |
+
if (timedEntries?.length) {
|
| 1167 |
+
return timedEntries.some((entry) => isPregameEntry(entry, now));
|
| 1168 |
+
}
|
| 1169 |
+
|
| 1170 |
+
return isPregameEntry(row, now);
|
| 1171 |
}
|
| 1172 |
|
| 1173 |
function extractStrikeoutLaneEntriesFromSnippet(text, section) {
|
test/market-scanner.test.js
CHANGED
|
@@ -456,7 +456,7 @@ test('movement alerts skip games that have already started', async () => {
|
|
| 456 |
entries: [
|
| 457 |
{
|
| 458 |
marketKey: 'julio|home_runs|yes|0.5',
|
| 459 |
-
source: '
|
| 460 |
book: 'Circa',
|
| 461 |
eventName: 'Mariners @ Astros',
|
| 462 |
eventCommenceTime: '2026-04-07T00:00:00Z',
|
|
@@ -491,7 +491,7 @@ test('movement alerts skip games that have already started', async () => {
|
|
| 491 |
entries: [
|
| 492 |
{
|
| 493 |
marketKey: 'julio|home_runs|yes|0.5',
|
| 494 |
-
source: '
|
| 495 |
book: 'Circa',
|
| 496 |
eventName: 'Mariners @ Astros',
|
| 497 |
eventCommenceTime: '2026-04-07T00:00:00Z',
|
|
|
|
| 456 |
entries: [
|
| 457 |
{
|
| 458 |
marketKey: 'julio|home_runs|yes|0.5',
|
| 459 |
+
source: 'circa',
|
| 460 |
book: 'Circa',
|
| 461 |
eventName: 'Mariners @ Astros',
|
| 462 |
eventCommenceTime: '2026-04-07T00:00:00Z',
|
|
|
|
| 491 |
entries: [
|
| 492 |
{
|
| 493 |
marketKey: 'julio|home_runs|yes|0.5',
|
| 494 |
+
source: 'circa',
|
| 495 |
book: 'Circa',
|
| 496 |
eventName: 'Mariners @ Astros',
|
| 497 |
eventCommenceTime: '2026-04-07T00:00:00Z',
|