implement user handling for trips

This commit is contained in:
2023-08-29 21:34:00 +02:00
parent ef4ef00d2c
commit be9be4c9da
28 changed files with 445 additions and 202 deletions

View File

@@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO trips_to_trips_types\n (trip_id, trip_type_id)\n VALUES\n (?, ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "0e8a12e168d8ff41005b2b5a1356ef5dc39339291572005e2a9278fb28113a2b"
}

View File

@@ -1,12 +1,12 @@
{
"db_name": "SQLite",
"query": "\n INSERT INTO trips_items\n (\n item_id,\n trip_id,\n pick,\n pack,\n ready,\n new\n )\n VALUES (?, ?, ?, ?, ?, ?)\n ",
"query": "\n INSERT INTO trips_items\n (\n item_id,\n trip_id,\n pick,\n pack,\n ready,\n new,\n user_id\n )\n VALUES (?, ?, ?, ?, ?, ?, ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 6
"Right": 7
},
"nullable": []
},
"hash": "86eb9fd598fbbb50b32ea7eae3151bfd8a83639c8b70301f5d5aeef19ae9462c"
"hash": "12167f7d6f8b1bfc5f37c214b089a5196039e6845598b8b22852b7665bcd5c0c"
}

View File

@@ -1,20 +0,0 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n i_item.id AS item_id\n FROM inventory_items AS i_item\n LEFT JOIN (\n SELECT t_item.item_id as item_id\n FROM trips_items AS t_item\n WHERE t_item.trip_id = ?\n ) AS t_item\n ON t_item.item_id = i_item.id\n WHERE t_item.item_id IS NULL\n ",
"describe": {
"columns": [
{
"name": "item_id",
"ordinal": 0,
"type_info": "Text"
}
],
"parameters": {
"Right": 1
},
"nullable": [
false
]
},
"hash": "1994305e1521fe1f5f927ad28e21c9cab8a25598b19e1c9038dae9092fe18f1f"
}

View File

@@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO trips\n (id, name, date_start, date_end, state)\n VALUES\n (?, ?, ?, ?, ?)",
"describe": {
"columns": [],
"parameters": {
"Right": 5
},
"nullable": []
},
"hash": "259757f1bb08f0c366371202c75b8555b878290b8a5a68564ec3e8b3d8e7ed01"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n category.id as category_id,\n category.name as category_name,\n category.description AS category_description,\n inner.trip_id AS trip_id,\n inner.item_id AS item_id,\n inner.item_name AS item_name,\n inner.item_description AS item_description,\n inner.item_weight AS item_weight,\n inner.item_is_picked AS item_is_picked,\n inner.item_is_packed AS item_is_packed,\n inner.item_is_ready AS item_is_ready,\n inner.item_is_new AS item_is_new\n FROM inventory_items_categories AS category\n LEFT JOIN (\n SELECT\n trip.trip_id AS trip_id,\n category.id as category_id,\n category.name as category_name,\n category.description as category_description,\n item.id as item_id,\n item.name as item_name,\n item.description as item_description,\n item.weight as item_weight,\n trip.pick as item_is_picked,\n trip.pack as item_is_packed,\n trip.ready as item_is_ready,\n trip.new as item_is_new\n FROM trips_items as trip\n INNER JOIN inventory_items as item\n ON item.id = trip.item_id\n INNER JOIN inventory_items_categories as category\n ON category.id = item.category_id\n WHERE trip.trip_id = ?\n ) AS inner\n ON inner.category_id = category.id\n ",
"query": "\n SELECT\n category.id as category_id,\n category.name as category_name,\n category.description AS category_description,\n inner.trip_id AS trip_id,\n inner.item_id AS item_id,\n inner.item_name AS item_name,\n inner.item_description AS item_description,\n inner.item_weight AS item_weight,\n inner.item_is_picked AS item_is_picked,\n inner.item_is_packed AS item_is_packed,\n inner.item_is_ready AS item_is_ready,\n inner.item_is_new AS item_is_new\n FROM inventory_items_categories AS category\n LEFT JOIN (\n SELECT\n trip.trip_id AS trip_id,\n category.id as category_id,\n category.name as category_name,\n category.description as category_description,\n item.id as item_id,\n item.name as item_name,\n item.description as item_description,\n item.weight as item_weight,\n trip.pick as item_is_picked,\n trip.pack as item_is_packed,\n trip.ready as item_is_ready,\n trip.new as item_is_new,\n trip.user_id as user_id\n FROM trips_items as trip\n INNER JOIN inventory_items as item\n ON item.id = trip.item_id\n INNER JOIN inventory_items_categories as category\n ON category.id = item.category_id\n WHERE trip.trip_id = ? AND trip.user_id = ?\n ) AS inner\n ON inner.category_id = category.id\n WHERE category.user_id = ?\n ",
"describe": {
"columns": [
{
@@ -65,7 +65,7 @@
}
],
"parameters": {
"Right": 1
"Right": 3
},
"nullable": [
false,
@@ -82,5 +82,5 @@
true
]
},
"hash": "a417bf136b8f79339a21fda10518c781d0d2bfc8c3fc99353d1956dfad9f5ac8"
"hash": "2793ec31c3345d77a824314bffa8a53cee248ac310fa620c272af1514f9ae951"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT\n id,\n name,\n CAST (date_start AS TEXT) date_start,\n CAST (date_end AS TEXT) date_end,\n state,\n location,\n temp_min,\n temp_max,\n comment\n FROM trips\n WHERE id = ?",
"query": "SELECT\n id,\n name,\n CAST (date_start AS TEXT) date_start,\n CAST (date_end AS TEXT) date_end,\n state,\n location,\n temp_min,\n temp_max,\n comment\n FROM trips\n WHERE user_id = ?",
"describe": {
"columns": [
{
@@ -64,5 +64,5 @@
true
]
},
"hash": "999fe09a6a095ac0ee7b3e3c38a6f2008641e03f9344f31bf9f8eb16a47403da"
"hash": "4753028574932a6b8d118deb65a930a1592512178477d210acfce662c857cf65"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n category.id as category_id,\n category.name as category_name,\n category.description AS category_description,\n inner.trip_id AS trip_id,\n inner.item_id AS item_id,\n inner.item_name AS item_name,\n inner.item_description AS item_description,\n inner.item_weight AS item_weight,\n inner.item_is_picked AS item_is_picked,\n inner.item_is_packed AS item_is_packed,\n inner.item_is_ready AS item_is_ready,\n inner.item_is_new AS item_is_new\n FROM inventory_items_categories AS category\n LEFT JOIN (\n SELECT\n trip.trip_id AS trip_id,\n category.id as category_id,\n category.name as category_name,\n category.description as category_description,\n item.id as item_id,\n item.name as item_name,\n item.description as item_description,\n item.weight as item_weight,\n trip.pick as item_is_picked,\n trip.pack as item_is_packed,\n trip.ready as item_is_ready,\n trip.new as item_is_new\n FROM trips_items as trip\n INNER JOIN inventory_items as item\n ON item.id = trip.item_id\n INNER JOIN inventory_items_categories as category\n ON category.id = item.category_id\n WHERE trip.trip_id = ?\n ) AS inner\n ON inner.category_id = category.id\n WHERE category.id = ?\n ",
"query": "\n SELECT\n category.id as category_id,\n category.name as category_name,\n category.description AS category_description,\n inner.trip_id AS trip_id,\n inner.item_id AS item_id,\n inner.item_name AS item_name,\n inner.item_description AS item_description,\n inner.item_weight AS item_weight,\n inner.item_is_picked AS item_is_picked,\n inner.item_is_packed AS item_is_packed,\n inner.item_is_ready AS item_is_ready,\n inner.item_is_new AS item_is_new\n FROM inventory_items_categories AS category\n LEFT JOIN (\n SELECT\n trip.trip_id AS trip_id,\n category.id as category_id,\n category.name as category_name,\n category.description as category_description,\n item.id as item_id,\n item.name as item_name,\n item.description as item_description,\n item.weight as item_weight,\n trip.pick as item_is_picked,\n trip.pack as item_is_packed,\n trip.ready as item_is_ready,\n trip.new as item_is_new\n FROM trips_items as trip\n INNER JOIN inventory_items as item\n ON item.id = trip.item_id\n INNER JOIN inventory_items_categories as category\n ON category.id = item.category_id\n WHERE \n trip.trip_id = ?\n AND trip.user_id = ?\n ) AS inner\n ON inner.category_id = category.id\n WHERE category.id = ?\n ",
"describe": {
"columns": [
{
@@ -65,7 +65,7 @@
}
],
"parameters": {
"Right": 2
"Right": 3
},
"nullable": [
false,
@@ -82,5 +82,5 @@
true
]
},
"hash": "343addb4024192688590b6b1228b9fdc554e2bbcc7e7300d8ca04cc4f23087d0"
"hash": "4878a57b32697b1f18e3d2bf58d34b1ad5d05976eec3432406a3d8ddf92d8b94"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n CAST(IFNULL(SUM(i_item.weight), 0) AS INTEGER) AS total_weight\n FROM trips AS trip\n INNER JOIN trips_items AS t_item\n ON t_item.trip_id = trip.id\n INNER JOIN inventory_items AS i_item\n ON t_item.item_id = i_item.id\n WHERE\n trip.id = ?\n AND t_item.pick = true\n ",
"query": "\n SELECT\n CAST(IFNULL(SUM(i_item.weight), 0) AS INTEGER) AS total_weight\n FROM trips AS trip\n INNER JOIN trips_items AS t_item\n ON t_item.trip_id = trip.id\n INNER JOIN inventory_items AS i_item\n ON t_item.item_id = i_item.id\n WHERE\n trip.id = ? AND trip.user_id = ?\n AND t_item.pick = true\n ",
"describe": {
"columns": [
{
@@ -10,11 +10,11 @@
}
],
"parameters": {
"Right": 1
"Right": 2
},
"nullable": [
false
]
},
"hash": "cc70d7a392a0283fec1896acba805f5c2a527537b8faa22d1c69306017b9c465"
"hash": "48c563fdbc8ca0dbe14726eda25a18780c6c416eda63b246daa75c5ff318331d"
}

View File

@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "INSERT INTO trips_types\n (id, name, user_id)\n VALUES\n (?, ?, ?)",
"describe": {
"columns": [],
"parameters": {
"Right": 3
},
"nullable": []
},
"hash": "4e24e535cc7c0dc0de572be4295ec187d7ad3742cb85371550bdaed2b780d7f5"
}

View File

@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "INSERT INTO\n trips_to_trips_types (trip_id, trip_type_id)\n SELECT trips.id as trip_id, trips_types.id as trip_type_id\n FROM trips\n INNER JOIN trips_types\n WHERE\n trips.id = ?\n AND trips.user_id = ?\n AND trips_types.id = ?\n AND trips_types.user_id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 4
},
"nullable": []
},
"hash": "5b1ddabd48e5407dae74a2f01eb2dbc3712ac4c2dcf48b90b6ec4ee8900ec2ef"
}

View File

@@ -1,12 +1,12 @@
{
"db_name": "SQLite",
"query": "UPDATE trips_types\n SET name = ?\n WHERE id = ?",
"query": "UPDATE trips_types\n SET name = ?\n WHERE id = ? and user_id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 2
"Right": 3
},
"nullable": []
},
"hash": "92ca05be21a4c05bf26f8a1655bbb8d9f1ece322abff5395ecacde3f6e28fdf7"
"hash": "5d27eb20c0f6c80bec63192b2ab89827bcf2b75fa75af1ce238530377e25d7bd"
}

View File

@@ -1,12 +1,12 @@
{
"db_name": "SQLite",
"query": "UPDATE trips\n SET state = ?\n WHERE id = ?",
"query": "UPDATE trips\n SET state = ?\n WHERE id = ? and user_id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 2
"Right": 3
},
"nullable": []
},
"hash": "3356a9ab2f217e3daf101644667c9d84f1547e0c72ab779e2f3aebb628a78034"
"hash": "6aa1ef65325521e8b2655445f8bf227a77ef1a24c8fcf722bf8e49beb8c7ba83"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n t_item.item_id AS id,\n t_item.pick AS picked,\n t_item.pack AS packed,\n t_item.ready AS ready,\n t_item.new AS new,\n i_item.name AS name,\n i_item.description AS description,\n i_item.weight AS weight,\n i_item.category_id AS category_id\n FROM trips_items AS t_item\n INNER JOIN inventory_items AS i_item\n ON i_item.id = t_item.item_id\n WHERE t_item.item_id = ?\n AND t_item.trip_id = ?\n ",
"query": "\n SELECT\n t_item.item_id AS id,\n t_item.pick AS picked,\n t_item.pack AS packed,\n t_item.ready AS ready,\n t_item.new AS new,\n i_item.name AS name,\n i_item.description AS description,\n i_item.weight AS weight,\n i_item.category_id AS category_id\n FROM trips_items AS t_item\n INNER JOIN inventory_items AS i_item\n ON i_item.id = t_item.item_id\n WHERE t_item.item_id = ?\n AND t_item.trip_id = ?\n AND t_item.user_id = ?\n ",
"describe": {
"columns": [
{
@@ -50,7 +50,7 @@
}
],
"parameters": {
"Right": 2
"Right": 3
},
"nullable": [
false,
@@ -64,5 +64,5 @@
false
]
},
"hash": "16c1a8c70c0778528502dcf1067f5b23d8fc8aaa6d61385b79bac4224a78d703"
"hash": "6fd3243228d59a7ac2266f0c181a78e7e7a312e101bdd9846123ee4de7c4751a"
}

View File

@@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "DELETE FROM trips_to_trips_types AS ttt\n WHERE ttt.trip_id = ?\n AND ttt.trip_type_id = ?\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "82395724cd85d8b57ce50a64f49386435fbebc83f18db53ab8650b29414e40fb"
}

View File

@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "INSERT INTO trips\n (id, name, date_start, date_end, state, user_id)\n VALUES\n (?, ?, ?, ?, ?, ?)",
"describe": {
"columns": [],
"parameters": {
"Right": 6
},
"nullable": []
},
"hash": "85c45093fb8d01ea07cb2f9ec94613b8117a437f07e22b0e8204687f8485b872"
}

View File

@@ -0,0 +1,20 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n i_item.id AS item_id\n FROM inventory_items AS i_item\n LEFT JOIN (\n SELECT t_item.item_id AS item_id, t_item.user_id AS user_id\n FROM trips_items AS t_item\n WHERE t_item.trip_id = ? AND t_item.user_id = ?\n ) AS t_item\n ON t_item.item_id = i_item.id\n WHERE t_item.item_id IS NULL AND i_item.user_id = ?",
"describe": {
"columns": [
{
"name": "item_id",
"ordinal": 0,
"type_info": "Text"
}
],
"parameters": {
"Right": 3
},
"nullable": [
false
]
},
"hash": "a5bedc046d5a4fd900903675794e7c3d8202d3876a26505cd26be7ceeb10d06d"
}

View File

@@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "DELETE FROM trips_to_trips_types AS ttt\n WHERE ttt.trip_id = ?\n AND ttt.trip_type_id = ?\n AND EXISTS(SELECT * FROM trips WHERE id = ? AND user_id = ?)\n AND EXISTS(SELECT * FROM trips_types WHERE id = ? AND user_id = ?)\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 6
},
"nullable": []
},
"hash": "b22e5d91f70638d4ed3b1592c661e470a0d80493e13478393f357da417a0208b"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT\n id,\n name\n FROM trips_types",
"query": "SELECT\n id,\n name\n FROM trips_types\n WHERE user_id = ?",
"describe": {
"columns": [
{
@@ -15,12 +15,12 @@
}
],
"parameters": {
"Right": 0
"Right": 1
},
"nullable": [
false,
false
]
},
"hash": "1eb9a8fdb9412753592f48a9267c97042aeaf6691546efae894e5d34ee92f34b"
"hash": "b36287d1b8c7905fb5fe6f8e9c73ca6f63b79252471ce4621d8692771e6fd3cc"
}

View File

@@ -1,12 +1,12 @@
{
"db_name": "SQLite",
"query": "UPDATE trips\n SET comment = ?\n WHERE id = ?",
"query": "UPDATE trips\n SET comment = ?\n WHERE id = ? AND user_id = ?",
"describe": {
"columns": [],
"parameters": {
"Right": 2
"Right": 3
},
"nullable": []
},
"hash": "a5cdb8a6d5850326815efd460c0b42dda02a4ea32713ec89beceb38cd24321d5"
"hash": "baea696b94b2f73ec46c645ed4f7ed355fab4bb37a56b9061bc37f3f053703cb"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT\n id,\n name,\n CAST (date_start AS TEXT) date_start,\n CAST (date_end AS TEXT) date_end,\n state,\n location,\n temp_min,\n temp_max,\n comment\n FROM trips",
"query": "SELECT\n id,\n name,\n CAST (date_start AS TEXT) date_start,\n CAST (date_end AS TEXT) date_end,\n state,\n location,\n temp_min,\n temp_max,\n comment\n FROM trips\n WHERE id = ? and user_id = ?",
"describe": {
"columns": [
{
@@ -50,7 +50,7 @@
}
],
"parameters": {
"Right": 0
"Right": 2
},
"nullable": [
false,
@@ -64,5 +64,5 @@
true
]
},
"hash": "6df16058d577c24a2aaaae71b2c3fd94ddf24e1ced343f3ea20872f0692a9ada"
"hash": "c1c2a52d3de684ac473206fa348ee792afe635b41eea4d32db30ac9775794520"
}

View File

@@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "\n SELECT\n type.id as id,\n type.name as name,\n inner.id IS NOT NULL AS active\n FROM trips_types AS type\n LEFT JOIN (\n SELECT type.id as id, type.name as name\n FROM trips as trip\n INNER JOIN trips_to_trips_types as ttt\n ON ttt.trip_id = trip.id\n INNER JOIN trips_types AS type\n ON type.id == ttt.trip_type_id\n WHERE trip.id = ?\n ) AS inner\n ON inner.id = type.id\n ",
"query": "\n SELECT\n type.id as id,\n type.name as name,\n inner.id IS NOT NULL AS active\n FROM trips_types AS type\n LEFT JOIN (\n SELECT type.id as id, trip.user_id as user_id\n FROM trips as trip\n INNER JOIN trips_to_trips_types as ttt\n ON ttt.trip_id = trip.id\n INNER JOIN trips_types AS type\n ON type.id == ttt.trip_type_id\n WHERE trip.id = ? AND trip.user_id = ?\n ) AS inner\n ON inner.id = type.id\n WHERE type.user_id = ?\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
}
],
"parameters": {
"Right": 1
"Right": 3
},
"nullable": [
false,
@@ -28,5 +28,5 @@
false
]
},
"hash": "1f08e9bebf51aab9cabff2a5c79211233a686e9ef9f96ea5c036fbba8f6b06d5"
"hash": "dd3f7d321b59961e4ab8a8c0946de1aff32eae0c645e9c544b48926f7ca16a66"
}

View File

@@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT INTO trips_types\n (id, name)\n VALUES\n (?, ?)",
"describe": {
"columns": [],
"parameters": {
"Right": 2
},
"nullable": []
},
"hash": "ded3be1c8894a64e3b5f749461db7261d9224abb8a54da980db8262733d08205"
}