diff options
Diffstat (limited to 'server/src/database.cppm')
| -rw-r--r-- | server/src/database.cppm | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/server/src/database.cppm b/server/src/database.cppm deleted file mode 100644 index 83616d2..0000000 --- a/server/src/database.cppm +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 1 | export module routemon:database; | ||
| 2 | |||
| 3 | import std; | ||
| 4 | import :sqlite3; | ||
| 5 | import :time; | ||
| 6 | |||
| 7 | namespace routemon::database { | ||
| 8 | |||
| 9 | namespace schema { | ||
| 10 | |||
| 11 | enum class rwgps_notification_cause | ||
| 12 | { | ||
| 13 | unknown, | ||
| 14 | created, | ||
| 15 | updated, | ||
| 16 | deleted, | ||
| 17 | added, | ||
| 18 | removed, | ||
| 19 | }; | ||
| 20 | |||
| 21 | enum class rwgps_notification_item_type | ||
| 22 | { | ||
| 23 | unknown, | ||
| 24 | trip, | ||
| 25 | route, | ||
| 26 | event, | ||
| 27 | event_participant, | ||
| 28 | club_member, | ||
| 29 | authorization, | ||
| 30 | }; | ||
| 31 | |||
| 32 | enum rwgps_notification_target_collection_type | ||
| 33 | { | ||
| 34 | unknown, | ||
| 35 | pinned, | ||
| 36 | }; | ||
| 37 | |||
| 38 | struct rwgps_notification_target_collection | ||
| 39 | { | ||
| 40 | std::int64_t notification_id = 0; | ||
| 41 | std::int64_t id; | ||
| 42 | rwgps_notification_target_collection_type type; | ||
| 43 | std::optional<std::string> url; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct rwgps_notification | ||
| 47 | { | ||
| 48 | std::int64_t id = 0; | ||
| 49 | time::timestamp<std::chrono::seconds> rwgps_timestamp; | ||
| 50 | // User that took the action | ||
| 51 | std::int64_t user_id; | ||
| 52 | rwgps_notification_item_type item_type; | ||
| 53 | std::optional<std::int64_t> item_id; | ||
| 54 | // User that owns the item | ||
| 55 | std::optional<std::int64_t> item_user_id; | ||
| 56 | std::optional<std::string> item_url; | ||
| 57 | rwgps_notification_cause action; | ||
| 58 | }; | ||
| 59 | |||
| 60 | } // namespace schema | ||
| 61 | |||
| 62 | export class connection | ||
| 63 | { | ||
| 64 | sqlite3::connection dbc_; | ||
| 65 | |||
| 66 | explicit connection(sqlite3::connection dbc) : dbc_{std::move(dbc)} {} | ||
| 67 | |||
| 68 | friend auto open(util::zstring_view filename) -> std::shared_ptr<connection>; | ||
| 69 | |||
| 70 | public: | ||
| 71 | auto insert_rwgps_notifications( | ||
| 72 | std::vector<std::pair< | ||
| 73 | schema::rwgps_notification, | ||
| 74 | std::optional<schema::rwgps_notification_target_collection> | ||
| 75 | >>& notifs) -> void; | ||
| 76 | }; | ||
| 77 | |||
| 78 | export auto open(util::zstring_view filename) -> std::shared_ptr<connection>; | ||
| 79 | |||
| 80 | } // namespace routemon::database | ||