lfqian commited on
Commit
ff53502
·
1 Parent(s): 8a6643b

Fix Join Arena time window sticking and isolate table-switch cache

Browse files
src/lib/dataService.js CHANGED
@@ -26,6 +26,7 @@ class DataService {
26
  this.assetOptions = []
27
  this.modelOptions = []
28
  this.strategyOptions = []
 
29
  }
30
 
31
  setSourceTable(tableName) {
@@ -41,6 +42,16 @@ class DataService {
41
  this.modelOptions = []
42
  this.strategyOptions = []
43
  clearAllDecisions()
 
 
 
 
 
 
 
 
 
 
44
  this._notify()
45
  return true
46
  }
@@ -437,6 +448,11 @@ class DataService {
437
  this._notify()
438
 
439
  try {
 
 
 
 
 
440
  // 1. 尝试从数据库加载筛选选项
441
  await this.loadFilterOptionsFromDb()
442
 
 
26
  this.assetOptions = []
27
  this.modelOptions = []
28
  this.strategyOptions = []
29
+ this.cacheResetPromise = null
30
  }
31
 
32
  setSourceTable(tableName) {
 
42
  this.modelOptions = []
43
  this.strategyOptions = []
44
  clearAllDecisions()
45
+ // Avoid cross-table cache pollution when switching between
46
+ // trading_decisions and challenge_table.
47
+ const resetPromise = clearAllStores()
48
+ .catch((e) => {
49
+ console.error('[DataService] Failed to clear cache on source switch:', e)
50
+ })
51
+ .finally(() => {
52
+ if (this.cacheResetPromise === resetPromise) this.cacheResetPromise = null
53
+ })
54
+ this.cacheResetPromise = resetPromise
55
  this._notify()
56
  return true
57
  }
 
448
  this._notify()
449
 
450
  try {
451
+ // Ensure source switch cache reset completes before any cache reads.
452
+ if (this.cacheResetPromise) {
453
+ await this.cacheResetPromise
454
+ }
455
+
456
  // 1. 尝试从数据库加载筛选选项
457
  await this.loadFilterOptionsFromDb()
458
 
src/views/RequestView.vue CHANGED
@@ -452,6 +452,7 @@ export default {
452
  return true
453
  },
454
  setDatesFromBounds(minTs, maxTs) {
 
455
  const dates = []
456
  const cur = new Date(minTs)
457
  const end = new Date(maxTs)
@@ -475,7 +476,14 @@ export default {
475
  const prev = Array.isArray(this.dateRange) ? this.dateRange : [0, this.maxDateIndex]
476
  const s = Math.max(0, Math.min(prev[0] ?? 0, this.maxDateIndex))
477
  const e = Math.max(0, Math.min(prev[1] ?? this.maxDateIndex, this.maxDateIndex))
478
- this.dateRange = [Math.min(s, e), Math.max(s, e)]
 
 
 
 
 
 
 
479
  },
480
  calculateVolatility(values) {
481
  if (!Array.isArray(values) || values.length < 2) return 0
 
452
  return true
453
  },
454
  setDatesFromBounds(minTs, maxTs) {
455
+ const oldMaxDateIndex = this.maxDateIndex
456
  const dates = []
457
  const cur = new Date(minTs)
458
  const end = new Date(maxTs)
 
476
  const prev = Array.isArray(this.dateRange) ? this.dateRange : [0, this.maxDateIndex]
477
  const s = Math.max(0, Math.min(prev[0] ?? 0, this.maxDateIndex))
478
  const e = Math.max(0, Math.min(prev[1] ?? this.maxDateIndex, this.maxDateIndex))
479
+ const wasPinnedToStartOnly = (prev[0] ?? 0) === 0 && (prev[1] ?? 0) === 0
480
+ const wasFullRange = (prev[0] ?? 0) === 0 && (prev[1] ?? oldMaxDateIndex) === oldMaxDateIndex
481
+ if (this.maxDateIndex > oldMaxDateIndex && (wasPinnedToStartOnly || wasFullRange)) {
482
+ // Data range grew; if previous selection was initial/full-range, keep it full-range.
483
+ this.dateRange = [0, this.maxDateIndex]
484
+ } else {
485
+ this.dateRange = [Math.min(s, e), Math.max(s, e)]
486
+ }
487
  },
488
  calculateVolatility(values) {
489
  if (!Array.isArray(values) || values.length < 2) return 0