Compare commits

...
4 Commits
Author SHA1 Message Date
dredgy 36b90a981f Rename number of flight achievements 2026-09-01 12:16:20 +10:00
dredgy 1e60ba5bbf Fixed distance achievements 2026-08-27 22:00:19 +10:00
dredgy 947f4839ce Urgent add carto API key 2026-08-27 21:49:46 +10:00
dredgy f31f1bc2fc Add airport search filter 2026-08-22 15:00:55 +10:00
8 changed files with 78 additions and 34 deletions
+14 -2
View File
@@ -58,12 +58,17 @@ class SearchController extends Controller
{
$q = request('q', '');
$len = strlen($q);
$includeInactive = request()->boolean('include_inactive');
$showClosed = request()->boolean('show_closed');
$showNoCode = request()->boolean('show_no_code');
if ($len < 3) return [];
return Airport::with('region.country')
->when(!$includeInactive, fn($query) => $query->where('active', true))
->when(!$showClosed, fn($query) => $query->where('active', true))
->when(!$showNoCode, fn($query) => $query->where(function ($sub) {
$sub->whereNotNull('iata_code')
->orWhereNotNull('icao_code');
}))
->when($len === 3, fn($query) => $query->where('iata_code', 'ilike', $q))
->when($len >= 4, fn($query) => $query->where(function ($sub) use ($q, $len) {
$sub->when($len === 4, fn($s) => $s->where('icao_code', 'ilike', $q))
@@ -75,6 +80,13 @@ class SearchController extends Controller
WHEN active THEN 0
ELSE 1
END
")
->orderByRaw("
CASE
WHEN iata_code IS NOT NULL AND icao_code IS NOT NULL THEN 0
WHEN iata_code IS NOT NULL OR icao_code IS NOT NULL THEN 1
ELSE 2
END
")
->orderByRaw("
CASE
@@ -58,6 +58,7 @@ class HandleInertiaRequests extends Middleware
->whereNull('expires_at')
->orWhere('expires_at', '>', now())
->count(),
'carto_api_key' => config('services.carto.key'),
];
}
}
@@ -19,7 +19,7 @@ class GeneralFlyingChecker extends BaseChecker
// --- Boolean achievements ---
$this->awardIf($allLoggedFlightsCount >= 1, 'general_flying.first_flight');
$this->awardIf($allLoggedFlightsCount >= 1, 'number_of_flights.first_flight');
$this->awardIf(
$flights->contains(fn ($f) => $f->isDomestic()),
@@ -69,10 +69,10 @@ class GeneralFlyingChecker extends BaseChecker
'general_flying.domestic_two_countries'
);
$this->awardProgress($count,'general_flying.10_flights');
$this->awardProgress($count,'general_flying.50_flights');
$this->awardProgress($count,'general_flying.100_flights');
$this->awardProgress($count,'general_flying.500_flights');
$this->awardProgress($count,'general_flying.1000_flights');
$this->awardProgress($count,'number_of_flights.10_flights');
$this->awardProgress($count,'number_of_flights.50_flights');
$this->awardProgress($count,'number_of_flights.100_flights');
$this->awardProgress($count,'number_of_flights.500_flights');
$this->awardProgress($count,'number_of_flights.1000_flights');
}
}
+4
View File
@@ -18,6 +18,10 @@ return [
'key' => env('POSTMARK_API_KEY'),
],
'carto' => [
'key' => env('CARTO_API_KEY'),
],
'resend' => [
'key' => env('RESEND_API_KEY'),
],
@@ -9,11 +9,7 @@ import ButtonLink from "@/Components/FlightsGoneBy/ButtonLink.vue";
import Distance from "@/Components/Distance.vue";
import FormattedNumber from "@/Components/FormattedNumber.vue";
const distanceAchievements = [
'general_flying.circumference_of_the_earth',
'general_flying.to_the_moon',
'general_flying.gigametre'
];
const distanceAchievementCategoryId = 6
const props = defineProps<{
achievement: Achievement
@@ -92,7 +88,7 @@ const unlocked = computed(() => {
<template v-if="achievement.progressive && progress">
<div class="progress-label">
<span v-if="distanceAchievements.includes(achievement.internal_name)">
<span v-if="achievement.achievement_category_id == distanceAchievementCategoryId">
<Distance :unit="distanceUnit" :showUnits="false" :value="Math.min(progress.current, progress.threshold)" /> /
<Distance :unit="distanceUnit" :value="progress.threshold" />
</span>
@@ -12,10 +12,14 @@ const model = defineModel<{ value: number, title: string, country_code: string }
const airportOptions = ref(props.prefilledOptions ?? [])
const autocompleteRef = ref<any>(null)
const includeInactive = ref(true)
const showClosed = ref(false)
const showNoCode = ref(false)
const lastQuery = ref('')
const menuOpen = ref(false)
const onFocus = () => {
menuOpen.value = true
nextTick(() => {
const input = autocompleteRef.value?.$el?.querySelector('input')
input?.select()
@@ -35,14 +39,15 @@ const searchAirports = async (query: string) => {
const { data } = await axios.get('/search/airports', {
params: {
q: query,
include_inactive: includeInactive.value ? 1 : undefined,
show_closed: showClosed.value ? 1 : undefined,
show_no_code: showNoCode.value ? 1 : undefined,
},
})
airportOptions.value = data
}
// Re-run the last search when the checkbox is toggled, so results update immediately
watch(includeInactive, () => {
// Re-run the last search when either checkbox is toggled, so results update immediately
watch([showClosed, showNoCode], () => {
if (lastQuery.value) searchAirports(lastQuery.value)
})
</script>
@@ -51,6 +56,7 @@ watch(includeInactive, () => {
<v-autocomplete
ref="autocompleteRef"
v-model="model"
v-model:menu="menuOpen"
:label="label ?? 'Airport'"
:items="airportOptions"
:error-messages="errorMessages"
@@ -62,6 +68,7 @@ watch(includeInactive, () => {
clearable
hide-no-data
return-object
autocomplete="off"
:custom-filter="() => true"
>
<template #prepend-inner>
@@ -69,6 +76,27 @@ watch(includeInactive, () => {
<span v-if="model" :class="`fi fi-${model.country_code}`"></span>
</span>
</template>
<template #prepend-item>
<div class="px-4 py-1 d-flex align-center" style="gap: 16px;" @mousedown.prevent>
<v-checkbox
v-model="showClosed"
label="Show Closed Airports"
density="compact"
hide-details
style="flex: none; transform: scale(0.65); transform-origin: left center;"
/>
<v-checkbox
v-model="showNoCode"
label="Show Airports with No Code"
density="compact"
hide-details
style="flex: none; transform: scale(0.65); transform-origin: left center;"
/>
</div>
<v-divider class="mt-1" />
</template>
<template #item="{ item, props: itemProps }">
<v-list-item v-bind="itemProps">
<template #prepend>
@@ -50,6 +50,7 @@ import {useUpdateSetting} from "@/Composables/useUpdateSetting";
import {usePage} from "@inertiajs/vue3";
type LngLat = [number, number]
interface RouteFlightBucket {
@@ -290,6 +291,7 @@ export default defineComponent({
const { updateSetting } = useUpdateSetting()
const page = usePage<SharedProps>().props
const carto_key = page.carto_api_key
let map: maplibregl.Map | null = null
let popup: maplibregl.Popup | null = null
@@ -736,10 +738,10 @@ export default defineComponent({
maxzoom: 19,
attribution: cartoAttribution.value,
tiles: [
'https://a.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png',
'https://b.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png',
'https://c.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png',
'https://d.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png',
`https://a.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png?key=${carto_key}`,
`https://b.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png?key=${carto_key}`,
`https://c.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png?key=${carto_key}`,
`https://d.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}@2x.png?key=${carto_key}`,
],
},
},
+1
View File
@@ -110,6 +110,7 @@ export type SharedProps = import('@inertiajs/core').PageProps & {
logo_api_url: string
achievement_notifications: Notification[]
unread_notification_count: number
carto_api_key: string
}
export interface AchievementDifficulty {
id: number