-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' for release v3.57.0
- Loading branch information
Showing
42 changed files
with
1,213 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "database/RatedArtist.hpp" | ||
|
||
#include <Wt/Dbo/WtSqlTraits.h> | ||
|
||
#include "database/Artist.hpp" | ||
#include "database/Session.hpp" | ||
#include "database/User.hpp" | ||
|
||
#include "IdTypeTraits.hpp" | ||
#include "Utils.hpp" | ||
|
||
namespace lms::db | ||
{ | ||
RatedArtist::RatedArtist(ObjectPtr<Artist> artist, ObjectPtr<User> user) | ||
: _artist{ getDboPtr(artist) } | ||
, _user{ getDboPtr(user) } | ||
{ | ||
} | ||
|
||
RatedArtist::pointer RatedArtist::create(Session& session, ObjectPtr<Artist> artist, ObjectPtr<User> user) | ||
{ | ||
return session.getDboSession()->add(std::unique_ptr<RatedArtist>{ new RatedArtist{ artist, user } }); | ||
} | ||
|
||
std::size_t RatedArtist::getCount(Session& session) | ||
{ | ||
session.checkReadTransaction(); | ||
return utils::fetchQuerySingleResult(session.getDboSession()->query<int>("SELECT COUNT(*) FROM rated_artist")); | ||
} | ||
|
||
RatedArtist::pointer RatedArtist::find(Session& session, RatedArtistId id) | ||
{ | ||
session.checkReadTransaction(); | ||
return utils::fetchQuerySingleResult(session.getDboSession()->find<RatedArtist>().where("id = ?").bind(id)); | ||
} | ||
|
||
RatedArtist::pointer RatedArtist::find(Session& session, ArtistId artistId, UserId userId) | ||
{ | ||
session.checkReadTransaction(); | ||
return utils::fetchQuerySingleResult(session.getDboSession()->find<RatedArtist>().where("artist_id = ?").bind(artistId).where("user_id = ?").bind(userId)); | ||
} | ||
|
||
void RatedArtist::find(Session& session, const FindParameters& params, std::function<void(const pointer&)> func) | ||
{ | ||
session.checkReadTransaction(); | ||
|
||
auto query{ session.getDboSession()->query<Wt::Dbo::ptr<RatedArtist>>("SELECT r_a FROM rated_artist r_a") }; | ||
|
||
if (params.user.isValid()) | ||
query.where("r_a.user_id = ?").bind(params.user); | ||
|
||
utils::forEachQueryRangeResult(query, params.range, func); | ||
} | ||
|
||
void RatedArtist::setLastUpdated(const Wt::WDateTime& lastUpdated) | ||
{ | ||
_lastUpdated = utils::normalizeDateTime(lastUpdated); | ||
} | ||
} // namespace lms::db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "database/RatedRelease.hpp" | ||
|
||
#include <Wt/Dbo/WtSqlTraits.h> | ||
|
||
#include "database/Release.hpp" | ||
#include "database/Session.hpp" | ||
#include "database/User.hpp" | ||
|
||
#include "IdTypeTraits.hpp" | ||
#include "Utils.hpp" | ||
|
||
namespace lms::db | ||
{ | ||
RatedRelease::RatedRelease(ObjectPtr<Release> release, ObjectPtr<User> user) | ||
: _release{ getDboPtr(release) } | ||
, _user{ getDboPtr(user) } | ||
{ | ||
} | ||
|
||
RatedRelease::pointer RatedRelease::create(Session& session, ObjectPtr<Release> release, ObjectPtr<User> user) | ||
{ | ||
return session.getDboSession()->add(std::unique_ptr<RatedRelease>{ new RatedRelease{ release, user } }); | ||
} | ||
|
||
std::size_t RatedRelease::getCount(Session& session) | ||
{ | ||
session.checkReadTransaction(); | ||
return utils::fetchQuerySingleResult(session.getDboSession()->query<int>("SELECT COUNT(*) FROM rated_release")); | ||
} | ||
|
||
RatedRelease::pointer RatedRelease::find(Session& session, RatedReleaseId id) | ||
{ | ||
session.checkReadTransaction(); | ||
return utils::fetchQuerySingleResult(session.getDboSession()->find<RatedRelease>().where("id = ?").bind(id)); | ||
} | ||
|
||
RatedRelease::pointer RatedRelease::find(Session& session, ReleaseId releaseId, UserId userId) | ||
{ | ||
session.checkReadTransaction(); | ||
return utils::fetchQuerySingleResult(session.getDboSession()->find<RatedRelease>().where("release_id = ?").bind(releaseId).where("user_id = ?").bind(userId)); | ||
} | ||
|
||
void RatedRelease::find(Session& session, const FindParameters& params, std::function<void(const pointer&)> func) | ||
{ | ||
session.checkReadTransaction(); | ||
|
||
auto query{ session.getDboSession()->query<Wt::Dbo::ptr<RatedRelease>>("SELECT r_r FROM rated_release r_r") }; | ||
|
||
if (params.user.isValid()) | ||
query.where("r_r.user_id = ?").bind(params.user); | ||
|
||
utils::forEachQueryRangeResult(query, params.range, func); | ||
} | ||
|
||
void RatedRelease::setLastUpdated(const Wt::WDateTime& lastUpdated) | ||
{ | ||
_lastUpdated = utils::normalizeDateTime(lastUpdated); | ||
} | ||
} // namespace lms::db |
Oops, something went wrong.