Spaces:
Running
Running
LiveView: query max date directly from Supabase instead of using cached end_date
Browse files- src/views/LiveView.vue +19 -11
src/views/LiveView.vue
CHANGED
|
@@ -174,6 +174,8 @@ import {
|
|
| 174 |
const orderedAssets = ['BTC','ETH','BMRN','TSLA']
|
| 175 |
const EXCLUDED_AGENT_NAMES = new Set(['vanilla', 'vinilla'])
|
| 176 |
|
|
|
|
|
|
|
| 177 |
const ASSET_ICONS = {
|
| 178 |
BTC: new URL('../assets/images/assets_images/BTC.png', import.meta.url).href,
|
| 179 |
ETH: new URL('../assets/images/assets_images/ETH.png', import.meta.url).href,
|
|
@@ -379,19 +381,25 @@ watch(
|
|
| 379 |
|
| 380 |
if (!perfs.length) { cards.value = []; return }
|
| 381 |
|
| 382 |
-
// Get max
|
| 383 |
const currentAsset = asset.value
|
| 384 |
-
const assetRows = (rowsRef.value || []).filter(r => r.asset === currentAsset && r.end_date)
|
| 385 |
let maxEndDate = null
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
}
|
| 396 |
|
| 397 |
// Buy & Hold first
|
|
|
|
| 174 |
const orderedAssets = ['BTC','ETH','BMRN','TSLA']
|
| 175 |
const EXCLUDED_AGENT_NAMES = new Set(['vanilla', 'vinilla'])
|
| 176 |
|
| 177 |
+
import { supabase } from '../lib/supabase'
|
| 178 |
+
|
| 179 |
const ASSET_ICONS = {
|
| 180 |
BTC: new URL('../assets/images/assets_images/BTC.png', import.meta.url).href,
|
| 181 |
ETH: new URL('../assets/images/assets_images/ETH.png', import.meta.url).href,
|
|
|
|
| 381 |
|
| 382 |
if (!perfs.length) { cards.value = []; return }
|
| 383 |
|
| 384 |
+
// Get max date directly from Supabase for this asset
|
| 385 |
const currentAsset = asset.value
|
|
|
|
| 386 |
let maxEndDate = null
|
| 387 |
+
try {
|
| 388 |
+
const { data, error } = await supabase
|
| 389 |
+
.from('trading_decisions')
|
| 390 |
+
.select('date')
|
| 391 |
+
.eq('asset', currentAsset)
|
| 392 |
+
.order('date', { ascending: false })
|
| 393 |
+
.limit(1)
|
| 394 |
+
|
| 395 |
+
if (!error && data && data.length > 0) {
|
| 396 |
+
maxEndDate = data[0].date
|
| 397 |
+
console.log('[LiveView] Direct Supabase query - Asset:', currentAsset, 'Max date:', maxEndDate)
|
| 398 |
+
} else {
|
| 399 |
+
console.log('[LiveView] Supabase query failed or no data:', error)
|
| 400 |
+
}
|
| 401 |
+
} catch (e) {
|
| 402 |
+
console.error('[LiveView] Error querying Supabase:', e)
|
| 403 |
}
|
| 404 |
|
| 405 |
// Buy & Hold first
|