Skip to content

Commit

Permalink
feat: cleanup after merge from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
tsshadow committed Jul 13, 2024
1 parent e1684a5 commit c9d446a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 73 deletions.
1 change: 0 additions & 1 deletion approot/tracks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
${<if-has-release>}${release class="d-none d-lg-inline text-truncate text-decoration-none link-success"}${</if-has-release>}
</div>
</div>

<div class="p-2 d-none d-sm-block text-muted text-center Lms-tracks-entry-rating">
${<if-has-rating>}${rating}${</if-has-rating>}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/libs/database/include/database/Track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ namespace lms::db
std::optional<std::size_t> getTrackNumber() const { return _trackNumber; }
std::optional<std::size_t> getTotalTrack() const { return _totalTrack; }
std::optional<std::size_t> getDiscNumber() const { return _discNumber; }
std::optional<std::size_t> getRating() const { return _rating; }
std::optional<std::size_t> getRating() const { return _rating; }
const std::string& getDiscSubtitle() const { return _discSubtitle; }
std::string getName() const { return _name; }
const std::filesystem::path& getAbsoluteFilePath() const { return _absoluteFilePath; }
Expand Down Expand Up @@ -327,7 +327,7 @@ namespace lms::db
int _scanVersion{};
std::optional<int> _trackNumber{};
std::optional<int> _discNumber{};
std::optional<int> _rating{};
std::optional<int> _rating{};
std::optional<int> _totalTrack{};
std::string _discSubtitle;
std::string _name;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/metadata/impl/AvFormatTagReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ namespace lms::metadata
_metaDataMap = audioFile->getMetaData();
_hasEmbeddedCover = audioFile->hasAttachedPictures();

// if (debug && core::Service<core::logging::ILogger>::get()->isSeverityActive(core::logging::Severity::DEBUG))
if (debug && core::Service<core::logging::ILogger>::get()->isSeverityActive(core::logging::Severity::DEBUG))
{
for (const auto& [key, value] : _metaDataMap)
LMS_LOG(METADATA, INFO, "AV Key = '" << key << "', value = '" << value << "'");
LMS_LOG(METADATA, DEBUG, "Key = '" << key << "', value = '" << value << "'");
}
}
catch (av::Exception& e)
Expand Down
2 changes: 1 addition & 1 deletion src/libs/metadata/impl/TagLibTagReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ namespace lms::metadata
for (const auto& [key, values] : _propertyMap)
{
for (const auto& value : values)
LMS_LOG(METADATA, INFO, "TAG Key = '" << key << "', value = '" << value.to8Bit(true) << "'");
LMS_LOG(METADATA, DEBUG, "Key = '" << key << "', value = '" << value.to8Bit(true) << "'");
}

for (const auto& value : _propertyMap.unsupportedData())
Expand Down
1 change: 0 additions & 1 deletion src/libs/subsonic/impl/SubsonicResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ namespace lms::api::subsonic
TLSMonotonicMemoryResourceCleaner memoryResourceCleaner;

LMS_LOG(API_SUBSONIC, DEBUG, "Handling request " << requestId << " '" << request.pathInfo() << "', continuation = " << (request.continuation() ? "true" : "false") << ", params = " << parameterMapToDebugString(request.getParameterMap()));
std::cout<< "Handling request " << requestId << " '" << request.pathInfo() << "', continuation = " << (request.continuation() ? "true" : "false") << ", params = " << parameterMapToDebugString(request.getParameterMap());

std::string requestPath{ request.pathInfo() };
if (core::stringUtils::stringEndsWith(requestPath, ".view"))
Expand Down
97 changes: 31 additions & 66 deletions src/libs/subsonic/impl/entrypoints/Browsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,29 @@ namespace lms::api::subsonic
std::map<char, std::vector<ArtistId>> artistsSortedByFirstChar;
std::size_t currentArtistOffset{ 0 };
constexpr std::size_t batchSize{ 100 };
// bool hasMoreArtists{ true };
// while (hasMoreArtists)
// {
// auto transaction{ context.dbSession.createReadTransaction() };
//
// parameters.setRange(Range{ currentArtistOffset, batchSize });
// const auto artists{ Artist::find(context.dbSession, parameters) };
// for (const Artist::pointer& artist : artists.results)
// {
// std::string_view sortName{ artist->getSortName() };
//
// char sortChar;
// if (sortName.empty() || !std::isalpha(sortName[0]))
// sortChar = '?';
// else
// sortChar = std::toupper(sortName[0]);
//
// artistsSortedByFirstChar[sortChar].push_back(artist->getId());
// }
//
// hasMoreArtists = artists.moreResults;
// currentArtistOffset += artists.results.size();
// }
bool hasMoreArtists{ true };
while (hasMoreArtists)
{
auto transaction{ context.dbSession.createReadTransaction() };

parameters.setRange(Range{ currentArtistOffset, batchSize });
const auto artists{ Artist::find(context.dbSession, parameters) };
for (const Artist::pointer& artist : artists.results)
{
std::string_view sortName{ artist->getSortName() };

char sortChar;
if (sortName.empty() || !std::isalpha(sortName[0]))
sortChar = '?';
else
sortChar = std::toupper(sortName[0]);

artistsSortedByFirstChar[sortChar].push_back(artist->getId());
}

hasMoreArtists = artists.moreResults;
currentArtistOffset += artists.results.size();
}

// second pass: add each artist
LMS_LOG(API_SUBSONIC, DEBUG, "GetArtists: constructing response...");
Expand Down Expand Up @@ -392,56 +392,21 @@ namespace lms::api::subsonic

Response handleGetYearsRequest(RequestContext& context)
{
Response response {Response::createOkResponse(context.serverProtocolVersion)};
Response response{ Response::createOkResponse(context.serverProtocolVersion) };

Response::Node& yearsNode {response.createNode("years")};
Response::Node& moodNode{ response.createNode("years") };

auto transaction{ context.dbSession.createReadTransaction() };

// const std::vector<int> years = Track::getAllYears(context.dbSession)};
std::vector<int> years = {
1992,
1993,
1994,
1995,
1996,
1997,
1998,
1999,
2000,
2001,
2002,
2003,
2004,
2005,
2006,
2007,
2008,
2009,
2010,
2011,
2012,
2013,
2014,
2015,
2016,
2017,
2018,
2019,
2020,
2021,
2022,
2023,
2024
};

for (const int year : years)
const ClusterType::pointer clusterType{ ClusterType::find(context.dbSession, "YEAR") };
if (clusterType)
{
Response::Node yearNode;
const auto clusters{ clusterType->getClusters() };

yearNode.setValue(year);
yearsNode.addArrayChild("year", Response::Node(yearNode));
for (const Cluster::pointer& cluster : clusters)
moodNode.addArrayChild("year", createGenreNode(cluster));
}

return response;
}

Expand Down

0 comments on commit c9d446a

Please sign in to comment.