aglinxinyuan opened a new pull request, #7038:
URL: https://github.com/apache/texera/pull/7038
### What changes were proposed in this PR?
Removes two pieces of frontend state that are maintained but not needed. No
behaviour change.
**1. `OperatorPaginationResultService.getPrevStats` is dead API.**
`getPrevStats()` has no caller in `src/` — not from TypeScript, not from a
template. Its backing field `prevStatsCache` exists only to feed it, so the
whole rotate-into-the-previous-slot dance in `handleStatsUpdate` serves a
reader that does not exist. The `if (!this.statsCache)` branch is also
unreachable: `statsCache` is initialised to `{}` and only ever reassigned to
another object.
```ts
// before
public handleStatsUpdate(statsUpdate): void {
if (!this.statsCache) {
this.statsCache = statsUpdate;
this.prevStatsCache = statsUpdate;
} else {
this.prevStatsCache = this.statsCache;
this.statsCache = statsUpdate;
}
}
// after
public handleStatsUpdate(statsUpdate): void {
this.statsCache = statsUpdate;
}
```
This does **not** touch `WorkflowResultService.getResultTableStats()`, which
is the mechanism actually used to deliver previous/current stats pairs to the
UI (via rxjs `pairwise()`).
**2. `SearchBarComponent.queryOrder` duplicates `Map` insertion order.**
The search cache kept a parallel `string[]` purely to know which key to
evict next. A JavaScript `Map` already iterates in insertion order, and
`addToCache` is only reached on a cache **miss** (a hit returns early at
`getSearchResults`), so the array can never diverge from the Map's own key
order — the oldest key is always `searchCache.keys().next().value`.
```ts
// before
if (this.queryOrder.length >= 20) {
const oldestQuery = this.queryOrder.shift();
this.searchCache.delete(oldestQuery!);
}
this.queryOrder.push(query);
this.searchCache.set(query, results);
// after
if (this.searchCache.size >= 20) {
const oldestQuery = this.searchCache.keys().next().value;
this.searchCache.delete(oldestQuery!);
}
this.searchCache.set(query, results);
```
Both existing tests were kept and re-pointed at the surviving API rather
than dropped, so eviction order and stats replacement are still pinned.
−23 lines, +13.
### Any related issues, documentation, discussions?
Closes #7037
### How was this PR tested?
Existing tests, updated in place to assert the same behaviour through the
surviving API:
- `search-bar.component.spec.ts` — the eviction test now reads
`[...cache.keys()]` instead of the removed `queryOrder` array. Same assertions:
`q0` evicted, `q1` oldest, `q20` newest, size stays 20.
- `workflow-result.service.spec.ts` — `handleStatsUpdate` is now asserted to
replace the current stats (it no longer has a previous slot to rotate into).
Locally:
- `npx tsc --noEmit -p frontend/tsconfig.json` — exit 0.
- `ng test --watch=false --include='**/search-bar.component.spec.ts'
--include='**/workflow-result.service.spec.ts'` — 39 tests, all pass.
- `prettier-eslint --list-different "src/**/*.{ts,js,html,scss,less,json}"`
— no differences.
Verification that nothing references the removed members:
```
grep -rn "prevStatsCache\|getPrevStats\|queryOrder" frontend/src
```
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]