mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 04:56:20 +00:00
[Character] Convert NoRentExpired to Repositories (#3860)
* [Character] Convert NoRentExpired to Repositories - Create a custom `GetSecondsSinceLastLogin` repository method to use in `NoRentExpired`. * Update character_data_repository.h
This commit is contained in:
@@ -46,6 +46,24 @@ public:
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
static uint32 GetSecondsSinceLastLogin(Database &db, const std::string& name)
|
||||
{
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT (UNIX_TIMESTAMP(NOW()) - last_login) FROM {} WHERE name = '{}'",
|
||||
TableName(),
|
||||
Strings::Escape(name)
|
||||
)
|
||||
);
|
||||
|
||||
if (!results.RowCount() || !results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return Strings::ToUnsignedInt(row[0]);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_CHARACTER_DATA_REPOSITORY_H
|
||||
|
||||
Reference in New Issue
Block a user