Optimized diff scan by not pulling the whole track columns

This commit is contained in:
emeric
2025-07-06 11:36:28 +02:00
parent 1b73ae1e8c
commit 25073b3ebc
4 changed files with 31 additions and 4 deletions
+19
View File
@@ -258,6 +258,25 @@ namespace lms::db
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<Track>>("SELECT t from track t").where("t.absolute_file_path = ?").bind(p));
}
std::optional<FileInfo> Track::findFileInfo(Session& session, const std::filesystem::path& p)
{
session.checkReadTransaction();
auto query{ session.getDboSession()->query<std::tuple<int, Wt::WDateTime>>("SELECT t.scan_version, t.file_last_write FROM track t WHERE t.absolute_file_path = ?") };
query.bind(p);
std::optional<FileInfo> result;
utils::forEachQueryResult(query, [&](const auto& row) {
FileInfo info;
info.scanVersion = std::get<0>(row);
info.lastWrittenTime = std::get<1>(row);
result = info;
});
return result;
}
Track::pointer Track::find(Session& session, TrackId id)
{
session.checkReadTransaction();