log-handle-external-boats #439

Merged
philipp merged 3 commits from log-handle-external-boats into staging 2024-04-24 17:03:43 +02:00
2 changed files with 13 additions and 15 deletions
Showing only changes of commit 237377dc05 - Show all commits

View File

@ -180,10 +180,14 @@ AND date('now') BETWEEN start_date AND end_date;",
if boat.is_locked(db).await { if boat.is_locked(db).await {
damage = BoatDamage::Locked; damage = BoatDamage::Locked;
} }
let cat = if boat.default_shipmaster_only_steering { let cat = if boat.external {
format!("Vereinsfremde Boote")
} else {
if boat.default_shipmaster_only_steering {
format!("{}+", boat.amount_seats - 1) format!("{}+", boat.amount_seats - 1)
} else { } else {
format!("{}x", boat.amount_seats) format!("{}x", boat.amount_seats)
}
}; };
res.push(BoatWithDetails { res.push(BoatWithDetails {
@ -259,7 +263,7 @@ ORDER BY
" "
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
FROM boat FROM boat
WHERE owner is null or owner = ? WHERE (owner is null or owner = ?) AND deleted = 0
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
", ",
user.id user.id
@ -273,7 +277,7 @@ ORDER BY amount_seats DESC
" "
SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
FROM boat FROM boat
WHERE owner = ? OR (owner is null and amount_seats = 1) WHERE (owner = ? OR (owner is null and amount_seats = 1)) AND deleted = 0
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
", ",
user.id user.id
@ -291,7 +295,7 @@ ORDER BY amount_seats DESC
Boat, Boat,
"SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible "SELECT id, name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
FROM boat FROM boat
WHERE owner is null and location_id = ? WHERE (owner is null and location_id = ?) AND deleted = 0
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
",ottensheim.id) ",ottensheim.id)
.fetch_all(db) .fetch_all(db)
@ -311,7 +315,7 @@ ORDER BY amount_seats DESC
SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible SELECT boat.id, boat.name, amount_seats, location_id, owner, year_built, boatbuilder, default_shipmaster_only_steering, default_destination, skull, external, deleted, convert_handoperated_possible
FROM boat FROM boat
INNER JOIN location ON boat.location_id = location.id INNER JOIN location ON boat.location_id = location.id
WHERE location.name=? WHERE location.name=? AND deleted = 0
ORDER BY amount_seats DESC ORDER BY amount_seats DESC
", ",
location location

View File

@ -3,16 +3,10 @@
Inputs: boats Inputs: boats
#} #}
{% macro show_boats() %} {% macro show_boats() %}
{% for amount_seats, grouped_boats in boats | group_by(attribute="cat") %} {% for cat, grouped_boats in boats | group_by(attribute="cat") %}
<details> <details>
<summary class="font-bold cursor-pointer text-primary-900 dark:text-white border-t p-3 hover:bg-gray-100 dark:hover:bg-primary-950"> <summary class="font-bold cursor-pointer text-primary-900 dark:text-white border-t p-3 hover:bg-gray-100 dark:hover:bg-primary-950">
<span> <span>{{ cat }}</span>
{% if grouped_boats[0].external %}
Vereinsfremde Boote
{% else %}
{{ grouped_boats[0].cat }}
{% endif %}
</span>
<small class="text-gray-500 dark:text-gray-100">({{ grouped_boats | length }})</small> <small class="text-gray-500 dark:text-gray-100">({{ grouped_boats | length }})</small>
</summary> </summary>
<div class="pb-3"> <div class="pb-3">