(afterId: number)
| 159 | * Returns entries and gap info if the buffer has overflowed. |
| 160 | */ |
| 161 | export function getActivityAfter(afterId: number): { |
| 162 | entries: ActivityEntry[]; |
| 163 | gap: boolean; |
| 164 | gapFrom?: number; |
| 165 | availableFrom?: number; |
| 166 | totalAdded: number; |
| 167 | } { |
| 168 | const total = activityBuffer.totalAdded; |
| 169 | const allEntries = activityBuffer.toArray(); |
| 170 | |
| 171 | if (afterId === 0) { |
| 172 | return { entries: allEntries, gap: false, totalAdded: total }; |
| 173 | } |
| 174 | |
| 175 | // Check for gap: if afterId is too old and has been evicted |
| 176 | const oldestId = allEntries.length > 0 ? allEntries[0].id : nextId; |
| 177 | if (afterId < oldestId) { |
| 178 | return { |
| 179 | entries: allEntries, |
| 180 | gap: true, |
| 181 | gapFrom: afterId + 1, |
| 182 | availableFrom: oldestId, |
| 183 | totalAdded: total, |
| 184 | }; |
| 185 | } |
| 186 | |
| 187 | // Filter to entries after the cursor |
| 188 | const filtered = allEntries.filter(e => e.id > afterId); |
| 189 | return { entries: filtered, gap: false, totalAdded: total }; |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Get the N most recent activity entries. |
no test coverage detected