1 parent
97dc183bdf
commit
e7573fbcd0
6 files changed
+193
-22
No files matched your search
@@ -64,6 +64,27 @@ namespace Echoion::Api
|
||||
uint64_t mostPlayedCount = 0;
|
||||
};
|
||||
|
||||
// Server-wide aggregate statistics (web dashboard)
|
||||
struct AggregateStats {
|
||||
uint64_t tracksToday = 0; // completed plays today
|
||||
uint64_t listeningMsToday = 0; // summed play duration today
|
||||
uint64_t queueAdditionsToday = 0;
|
||||
uint64_t skipsToday = 0;
|
||||
uint64_t playsTotal = 0;
|
||||
uint64_t skipsTotal = 0;
|
||||
// Most active requesters, most additions first.
|
||||
struct TopRequester {
|
||||
std::string uid; // TeamSpeak uid (may be empty for old rows)
|
||||
std::string nickname;
|
||||
uint64_t count = 0;
|
||||
};
|
||||
std::vector<TopRequester> topRequesters;
|
||||
// Source split over the whole history
|
||||
uint64_t youtubeCount = 0;
|
||||
uint64_t yandexCount = 0;
|
||||
uint64_t otherCount = 0;
|
||||
};
|
||||
|
||||
// Main database interface
|
||||
class Database
|
||||
{
|
||||
@@ -158,6 +179,14 @@ namespace Echoion::Api
|
||||
[[nodiscard]] Api::Result<std::vector<TrackInfo>>
|
||||
getRecentlyPlayed(uint64_t userId, size_t limit = 20);
|
||||
|
||||
// Record a skipped track (playback aborted by user action)
|
||||
Api::Result<void> recordSkip(const TrackInfo& track,
|
||||
uint64_t playedBy);
|
||||
|
||||
// Log a queue addition (daily stats / top requesters)
|
||||
Api::Result<void> logQueueAddition(const std::string& uid,
|
||||
const std::string& nickname);
|
||||
|
||||
// ===== Favorites =====
|
||||
|
||||
// Add track to favorites
|
||||
@@ -189,6 +218,9 @@ namespace Echoion::Api
|
||||
std::vector<std::pair<TrackInfo, uint64_t>>>
|
||||
getMostPlayed(uint64_t userId, size_t limit = 10);
|
||||
|
||||
// Get server-wide aggregate statistics (web dashboard)
|
||||
[[nodiscard]] Api::Result<AggregateStats> getAggregateStats();
|
||||
|
||||
// ===== Key/value store =====
|
||||
// Small persisted state (healthy instance lists, ...). Values
|
||||
// are opaque strings (callers serialize as needed).
|
||||
@@ -197,6 +229,53 @@ namespace Echoion::Api
|
||||
Api::Result<void> setKv(const std::string& key,
|
||||
const std::string& value);
|
||||
|
||||
// ===== Custom emojis (web UI image emotes) =====
|
||||
// Admin-managed image emotes referenced by :name: shortcodes in
|
||||
// watch chat/reactions. `data` is base64-encoded image bytes.
|
||||
struct CustomEmoji {
|
||||
std::string name;
|
||||
std::string mime;
|
||||
std::string dataBase64;
|
||||
std::string addedBy;
|
||||
};
|
||||
[[nodiscard]] Api::Result<std::vector<CustomEmoji>>
|
||||
getCustomEmojis();
|
||||
// Image (mime + base64 data) for one emoji name, or nullopt.
|
||||
[[nodiscard]] Api::Result<std::optional<CustomEmoji>>
|
||||
getCustomEmoji(const std::string& name);
|
||||
Api::Result<void> addCustomEmoji(const std::string& name,
|
||||
const std::string& mime,
|
||||
const std::string& dataBase64,
|
||||
const std::string& addedBy);
|
||||
Api::Result<void> removeCustomEmoji(const std::string& name);
|
||||
|
||||
// ===== Cached avatars (web UI) =====
|
||||
// TeamSpeak avatar images persisted by uid so the web UI can show
|
||||
// them even when the client is offline or out of the bot's view
|
||||
// (the live TS avatar cache only holds in-view clients). `data` is
|
||||
// base64-encoded image bytes, like custom emojis.
|
||||
struct CachedAvatar {
|
||||
std::string uid;
|
||||
std::string mime;
|
||||
std::string dataBase64;
|
||||
// The source myTeamSpeak avatar URL, so an offline user's
|
||||
// avatar can be re-fetched even when the image bytes were
|
||||
// never stored. Empty for legacy/file avatars.
|
||||
std::string url;
|
||||
};
|
||||
// Image (mime + base64 data + url) for one uid, or nullopt if none.
|
||||
[[nodiscard]] Api::Result<std::optional<CachedAvatar>>
|
||||
getCachedAvatar(const std::string& uid);
|
||||
// Insert or replace the cached avatar image for a uid (keeps any
|
||||
// previously stored url).
|
||||
Api::Result<void> putCachedAvatar(const std::string& uid,
|
||||
const std::string& mime,
|
||||
const std::string& dataBase64);
|
||||
// Record just the source url for a uid (upsert), so it survives to
|
||||
// be re-fetched after the user goes offline.
|
||||
Api::Result<void> putCachedAvatarUrl(const std::string& uid,
|
||||
const std::string& url);
|
||||
|
||||
// ===== Subscriptions =====
|
||||
|
||||
// Subscriber info
|
||||
|
||||
Reference in new issue
Block a user