Remove prediction API endpoint and integrate into stations search
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

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:
Ovidiu U
2026-04-29 13:28:33 +01:00
parent ee6de23709
commit 088fd11058
29 changed files with 1046 additions and 499 deletions

View File

@@ -39,7 +39,7 @@
<!-- Prediction box (sits above filter results) -->
<PredictionCard
:is-paid-tier="showFullPrediction"
:loading="predictionLoading"
:loading="loading"
:prediction="prediction"
/>
@@ -81,6 +81,7 @@
:radius-miles="radiusMiles"
:stations="filteredStations"
/>
<UpsellBanner :station-count="liveStats.stationCount" />
<StationList
:current-sort="sort"
:origin="searchOrigin"
@@ -236,7 +237,7 @@
</div>
</div>
<ul class="space-y-4 mb-8 flex-1">
<li class="text-sm flex gap-2"><iconify-icon class="text-accent" icon="lucide:check"></iconify-icon> Ad-free Experience</li>
<li class="text-sm flex gap-2"><iconify-icon class="text-accent" icon="lucide:check"></iconify-icon> Buy-or-Wait Score</li>
<li class="text-sm flex gap-2"><iconify-icon class="text-accent" icon="lucide:check"></iconify-icon> 14-day Trend Data</li>
<li class="text-sm flex gap-2"><iconify-icon class="text-accent" icon="lucide:check"></iconify-icon> 3 Daily Price Alerts</li>
</ul>
@@ -385,7 +386,7 @@ import api from '../axios.js'
import PostSearchFilters from '../components/PostSearchFilters.vue'
import PredictionCard from '../components/PredictionCard.vue'
import StationList from '../components/StationList.vue'
import { usePrediction } from '../composables/usePrediction.js'
import UpsellBanner from '../components/UpsellBanner.vue'
const LeafletMap = defineAsyncComponent(() => import('../components/LeafletMap.vue'))
import LandingNav from '../components/landing/LandingNav.vue'
@@ -395,8 +396,6 @@ import HeroSearch from '../components/landing/HeroSearch.vue'
import StatsRow from '../components/landing/StatsRow.vue'
const { isAuthenticated, userTier } = useAuth()
const { prediction, loading: predictionLoading, fetch: fetchPrediction } = usePrediction()
const showFullPrediction = computed(() => Boolean(prediction.value) && !prediction.value.tier_locked)
const liveStats = ref({ stationCount: null, latestPriceAt: null })
@@ -446,7 +445,8 @@ const PRICES = {
annual: { basic: '£9.90', plus: '£24.90', pro: '£39.90' },
}
const PRICE_SUFFIX = { monthly: '/mo', annual: '/yr' }
const { stations, meta, loading, error, search, reset } = useStations()
const { stations, meta, prediction, loading, error, search, reset } = useStations()
const showFullPrediction = computed(() => Boolean(prediction.value) && !prediction.value.tier_locked)
watch(loading, (isLoading) => {
if (!isLoading) return
@@ -557,9 +557,6 @@ async function runSearch(params) {
radiusMiles.value = params.radius ?? radiusMiles.value
searchAttempted.value = true
await search(params)
const lat = meta.value?.lat ?? params.lat ?? null
const lng = meta.value?.lng ?? params.lng ?? null
fetchPrediction(lat && lng ? { lat, lng } : {})
}
async function onSearch(params) {