Remove prediction API endpoint and integrate into stations search
Consolidate prediction functionality by merging /api/prediction endpoint into /api/stations response. Move prediction logic from PredictionController into StationController, returning prediction data alongside station results. Replace usePrediction composable with unified useStations that returns {stations, meta, prediction}. Remove PredictionRequest, related tests, and unused Vue components (FuelFinderTest, MapTest, RecommendationTest, StationListTest). Add PredictionFull component and UpsellBanner. Extend NationalFuelPredictionService to include weekly_summary (7-day series, yesterday/today averages, cheapest/priciest days) and oil signal from price_predictions table. Update Home.vue to consume prediction from stations response. Add Plan::resolveCadenceForUser helper and configure Cashier to use custom Subscription model.
This commit is contained in:
@@ -29,40 +29,13 @@
|
||||
</div>
|
||||
|
||||
<!-- Paid: full prediction -->
|
||||
<div
|
||||
v-else-if="prediction"
|
||||
class="p-6 bg-white rounded-2xl border border-zinc-300 space-y-4"
|
||||
>
|
||||
<p class="text-xs font-bold uppercase tracking-widest text-zinc-500">Price Prediction</p>
|
||||
|
||||
<h3
|
||||
:class="['text-2xl font-black', actionTextColor]"
|
||||
>
|
||||
{{ actionLabel }}
|
||||
</h3>
|
||||
|
||||
<div class="w-full h-2 bg-zinc-200 rounded-full overflow-hidden">
|
||||
<div
|
||||
:class="['h-full rounded-full transition-all', actionBarColor]"
|
||||
:style="{ width: prediction.confidence_score + '%' }"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<p class="text-sm text-zinc-500 leading-relaxed">{{ prediction.reasoning }}</p>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-zinc-500 font-medium">
|
||||
<span>Avg: {{ prediction.current_avg }}p</span>
|
||||
<span>Confidence: {{ prediction.confidence_label }}</span>
|
||||
<span v-if="prediction.predicted_change_pence">
|
||||
{{ prediction.predicted_change_pence > 0 ? '+' : '' }}{{ prediction.predicted_change_pence.toFixed(1) }}p expected
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<PredictionFull v-else :prediction="prediction" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import PredictionFull from './PredictionFull.vue'
|
||||
|
||||
const props = defineProps({
|
||||
prediction: { type: Object, default: null },
|
||||
@@ -70,31 +43,6 @@ const props = defineProps({
|
||||
isPaidTier: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const actionLabel = computed(() => {
|
||||
if (!props.prediction) return ''
|
||||
return {
|
||||
fill_now: 'Fill up now',
|
||||
wait: 'Wait — prices falling',
|
||||
no_signal: 'No clear signal',
|
||||
}[props.prediction.action] ?? 'Check local prices'
|
||||
})
|
||||
|
||||
const actionTextColor = computed(() => {
|
||||
if (!props.prediction) return 'text-zinc-800'
|
||||
return {
|
||||
fill_now: 'text-mauve',
|
||||
wait: 'text-teal',
|
||||
}[props.prediction.action] ?? 'text-tan'
|
||||
})
|
||||
|
||||
const actionBarColor = computed(() => {
|
||||
if (!props.prediction) return 'bg-zinc-400'
|
||||
return {
|
||||
fill_now: 'bg-mauve',
|
||||
wait: 'bg-teal',
|
||||
}[props.prediction.action] ?? 'bg-tan'
|
||||
})
|
||||
|
||||
const direction = computed(() => props.prediction?.predicted_direction ?? 'stable')
|
||||
|
||||
const genericSentence = computed(() => ({
|
||||
|
||||
Reference in New Issue
Block a user