Optimized diff scan by not pulling the whole track columns
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -191,6 +191,7 @@ namespace lms::db
|
||||
// Find utility functions
|
||||
static std::size_t getCount(Session& session);
|
||||
static pointer findByPath(Session& session, const std::filesystem::path& p);
|
||||
static std::optional<FileInfo> findFileInfo(Session& session, const std::filesystem::path& p);
|
||||
static pointer find(Session& session, TrackId id);
|
||||
static void find(Session& session, TrackId& lastRetrievedId, std::size_t count, const std::function<void(const Track::pointer&)>& func, MediaLibraryId library = {});
|
||||
static void find(Session& session, const IdRange<TrackId>& idRange, const std::function<void(const Track::pointer&)>& func);
|
||||
|
||||
@@ -114,6 +114,12 @@ namespace lms::db
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct FileInfo
|
||||
{
|
||||
Wt::WDateTime lastWrittenTime;
|
||||
std::size_t scanVersion{};
|
||||
};
|
||||
|
||||
enum class ArtistSortMethod
|
||||
{
|
||||
None,
|
||||
|
||||
Reference in New Issue
Block a user