From aac119f34c507953360148cba2b8408d9fb4cb3e Mon Sep 17 00:00:00 2001 From: emeric Date: Thu, 20 Jan 2022 19:52:10 +0100 Subject: [PATCH] Removed unused files --- .../listenbrainz/FeedbackSynchronizer.hpp | 92 ------------------- .../impl/listenbrainz/LovesSynchronizer.hpp | 92 ------------------- 2 files changed, 184 deletions(-) delete mode 100644 src/libs/services/scrobbling/impl/listenbrainz/FeedbackSynchronizer.hpp delete mode 100644 src/libs/services/scrobbling/impl/listenbrainz/LovesSynchronizer.hpp diff --git a/src/libs/services/scrobbling/impl/listenbrainz/FeedbackSynchronizer.hpp b/src/libs/services/scrobbling/impl/listenbrainz/FeedbackSynchronizer.hpp deleted file mode 100644 index 0547921a..00000000 --- a/src/libs/services/scrobbling/impl/listenbrainz/FeedbackSynchronizer.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2021 Emeric Poupon - * - * This file is part of LMS. - * - * LMS is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LMS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LMS. If not, see . - */ - -#pragma once - -#include -#include -#include -#include - -#include "SendQueue.hpp" - -namespace Database -{ - class Db; - class Session; - class User; -} - -namespace Scrobbling::ListenBrainz -{ - class ListensSynchronizer - { - public: - FeedbackSynchronizer(boost::asio::io_context& ioContext, Database::Db& db, SendQueue& sendQueue); - - // void updateFeedback(const TimedListen& listen); - - private: - struct UserContext - { - UserContext(Database::UserId id) : userId {id} {} - - UserContext(const UserContext&) = delete; - UserContext(UserContext&&) = delete; - UserContext& operator=(const UserContext&) = delete; - UserContext& operator=(UserContext&&) = delete; - - const Database::UserId userId; - bool fetching {}; - std::optional listenCount {}; - - // resetted at each fetch - std::string listenBrainzUserName; // need to be resolved first - Wt::WDateTime maxDateTime; - std::size_t fetchedListenCount{}; - std::size_t matchedListenCount{}; - std::size_t importedListenCount{}; - }; - - UserContext& getUserContext(Database::UserId userId); - bool isFetching() const; - void scheduleGetListens(std::chrono::seconds fromNow); - void startGetListens(); - void startGetListens(UserContext& context); - void onGetListensEnded(UserContext& context); - void enqueValidateToken(UserContext& context); - void enqueGetListenCount(UserContext& context); - void enqueGetListens(UserContext& context); - std::optional createValidateTokenRequestData(Database::UserId userId); - std::optional createGetListensRequestData(std::string_view listenBrainzUserName, const Wt::WDateTime& maxDateTime); - void processGetListensResponse(std::string_view body, UserContext& context); - - boost::asio::io_context& _ioContext; - boost::asio::io_context::strand _strand {_ioContext}; - Database::Db& _db; - SendQueue& _sendQueue; - boost::asio::steady_timer _getListensTimer {_ioContext}; - - std::unordered_map _userContexts; - - const std::size_t _maxSyncFeedbackCount; - const std::chrono::hours _syncFeedbackPeriod; - }; -} // Scrobbling::ListenBrainz - diff --git a/src/libs/services/scrobbling/impl/listenbrainz/LovesSynchronizer.hpp b/src/libs/services/scrobbling/impl/listenbrainz/LovesSynchronizer.hpp deleted file mode 100644 index 0f7bf48f..00000000 --- a/src/libs/services/scrobbling/impl/listenbrainz/LovesSynchronizer.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2021 Emeric Poupon - * - * This file is part of LMS. - * - * LMS is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * LMS is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LMS. If not, see . - */ - -#pragma once - -#include -#include -#include -#include -#include - -#include "services/database/Types.hpp" -#include "services/scrobbling/Listen.hpp" - -namespace Database -{ - class Db; - class Session; - class TrackList; - class User; -} - -namespace Scrobbling::ListenBrainz -{ - class ListensSynchronizer - { - public: - ListensSynchronizer(boost::asio::io_context& ioContext, Database::Db& db, std::string_view baseAPIUrl); - - void saveListen(const TimedListen& listen); - - private: - struct UserContext - { - UserContext(Database::UserId id) : userId {id} {} - - UserContext(const UserContext&) = delete; - UserContext(UserContext&&) = delete; - UserContext& operator=(const UserContext&) = delete; - UserContext& operator=(UserContext&&) = delete; - - const Database::UserId userId; - bool fetching {}; - - // resetted at each fetch - std::string listenBrainzUserName; // need to be resolved first - Wt::WDateTime maxDateTime; - std::size_t fetchedLoveCount{}; - std::size_t matchedLoveCount{}; - std::size_t importedLoveCount{}; - }; - - UserContext& getUserContext(Database::UserId userId); - bool isFetching() const; - void scheduleGetListens(std::chrono::seconds fromNow); - void startGetListens(); - void startGetListens(UserContext& context); - void onGetListensEnded(UserContext& context); - void enqueValidateToken(UserContext& context); - void enqueGetListenCount(UserContext& context); - void enqueGetListens(UserContext& context); - void processGetListensResponse(std::string_view body, UserContext& context); - - boost::asio::io_context& _ioContext; - boost::asio::io_context::strand _strand {_ioContext}; - Database::Db& _db; - std::string _baseAPIUrl; - boost::asio::steady_timer _getListensTimer {_ioContext}; - - std::unordered_map _userContexts; - - const std::size_t _maxSyncListenCount; - const std::chrono::hours _syncListensPeriod; - }; -} // Scrobbling::ListenBrainz -