diff options
Diffstat (limited to 'src/database')
-rw-r--r-- | src/database/database.cpp | 9 | ||||
-rw-r--r-- | src/database/database.hpp | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/database/database.cpp b/src/database/database.cpp index fce0f45..48cdea8 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -136,6 +136,15 @@ void Database::store_muc_message(const std::string& owner, const Iid& iid, line.update(); } +std::vector<db::MucLogLine> Database::get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server, const int limit) +{ + auto res = litesql::select<db::MucLogLine>(*Database::db, + db::MucLogLine::Owner == owner && + db::MucLogLine::IrcChanName == chan_name && + db::MucLogLine::IrcServerName == server).orderBy(db::MucLogLine::Date, false).limit(limit).all(); + return {res.rbegin(), res.rend()}; +} + void Database::close() { Database::db.reset(nullptr); diff --git a/src/database/database.hpp b/src/database/database.hpp index d1be2fd..14012ff 100644 --- a/src/database/database.hpp +++ b/src/database/database.hpp @@ -48,6 +48,8 @@ public: static db::IrcChannelOptions get_irc_channel_options_with_server_and_global_default(const std::string& owner, const std::string& server, const std::string& channel); + static std::vector<db::MucLogLine> get_muc_logs(const std::string& owner, const std::string& chan_name, const std::string& server, + const int limit); static void store_muc_message(const std::string& owner, const Iid& iid, time_point date, const std::string& body, const std::string& nick); |