also looking at this
fix(dashboard): unshadow the bridged range so site switching works
#54
2 files
+45
-3
| @@ -1731,15 +1731,17 @@ async function importFromFathom(): Promise<void> { | ||
| 1731 | 1731 | else if (first.status === 413 && first.data.range?.from) { |
| 1732 | 1732 | // Too big for one request. Post the SAME files again in date windows, |
| 1733 | 1733 | // sized from the estimate the server just sent back. |
| 1734 | const range = first.data.range | |
| 1734 | // Not `range`: that name reaches this block from the server for switchSite, | |
| 1735 | // and the bridge withholds any name the block declares, even nested like this. | |
| 1736 | const importRange = first.data.range | |
| 1735 | 1737 | const total = Number(first.data.estimate?.pageViews ?? 0) |
| 1736 | 1738 | const max = Number(first.data.maxRows ?? 50000) |
| 1737 | const span = fathomWindows(range.from, range.to, 3650)[0] | |
| 1739 | const span = fathomWindows(importRange.from, importRange.to, 3650)[0] | |
| 1738 | 1740 | const allDays = Math.round((new Date(`${span[1]}T00:00:00Z`).getTime() - new Date(`${span[0]}T00:00:00Z`).getTime()) / 86400000) + 1 |
| 1739 | 1741 | // Two thirds of the cap per window, so an uneven distribution across the |
| 1740 | 1742 | // range does not push one window back over it. |
| 1741 | 1743 | const perWindow = Math.max(1, Math.floor(allDays * ((max * 0.66) / Math.max(total, 1)))) |
| 1742 | const windows = fathomWindows(range.from, range.to, perWindow) | |
| 1744 | const windows = fathomWindows(importRange.from, importRange.to, perWindow) | |
| 1743 | 1745 | |
| 1744 | 1746 | for (let i = 0; i < windows.length; i++) { |
| 1745 | 1747 | const [fromDay, toDay] = windows[i] |