Only display the type of tags that are actually in use in the filters button
This commit is contained in:
@@ -67,4 +67,4 @@ See [INSTALL.md](INSTALL.md) file.
|
|||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are welcome! Please prepare your pull requests on the [develop](../../tree/develop) branch.
|
Contributions are welcome! Please submit your pull requests against the [develop](../../tree/develop) branch.
|
||||||
|
|||||||
@@ -132,11 +132,25 @@ ClusterType::getAllOrphans(Session& session)
|
|||||||
{
|
{
|
||||||
session.checkSharedLocked();
|
session.checkSharedLocked();
|
||||||
|
|
||||||
Wt::Dbo::collection<pointer> res = session.getDboSession().query<Wt::Dbo::ptr<ClusterType>>("select c_t from cluster_type c_t LEFT OUTER JOIN cluster c ON c_t.id = c.cluster_type_id WHERE c.id IS NULL");
|
Wt::Dbo::collection<pointer> res = session.getDboSession().query<Wt::Dbo::ptr<ClusterType>>(
|
||||||
|
"SELECT c_t from cluster_type c_t"
|
||||||
|
" LEFT OUTER JOIN cluster c ON c_t.id = c.cluster_type_id")
|
||||||
|
.where("c.id IS NULL");
|
||||||
|
|
||||||
return std::vector<pointer>(res.begin(), res.end());
|
return std::vector<pointer>(res.begin(), res.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<ClusterType::pointer>
|
||||||
|
ClusterType::getAllUsed(Session& session)
|
||||||
|
{
|
||||||
|
session.checkSharedLocked();
|
||||||
|
|
||||||
|
Wt::Dbo::collection<pointer> res = session.getDboSession().query<Wt::Dbo::ptr<ClusterType>>(
|
||||||
|
"SELECT DISTINCT c_t from cluster_type c_t")
|
||||||
|
.join("cluster c ON c_t.id = c.cluster_type_id");
|
||||||
|
|
||||||
|
return std::vector<pointer>(res.begin(), res.end());
|
||||||
|
}
|
||||||
|
|
||||||
ClusterType::pointer
|
ClusterType::pointer
|
||||||
ClusterType::getByName(Session& session, const std::string& name)
|
ClusterType::getByName(Session& session, const std::string& name)
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ class ClusterType : public Wt::Dbo::Dbo<ClusterType>
|
|||||||
ClusterType(std::string name);
|
ClusterType(std::string name);
|
||||||
|
|
||||||
static std::vector<pointer> getAllOrphans(Session& session);
|
static std::vector<pointer> getAllOrphans(Session& session);
|
||||||
|
static std::vector<pointer> getAllUsed(Session& session);
|
||||||
static pointer getByName(Session& session, const std::string& name);
|
static pointer getByName(Session& session, const std::string& name);
|
||||||
static pointer getById(Session& session, IdType id);
|
static pointer getById(Session& session, IdType id);
|
||||||
static std::vector<pointer> getAll(Session& session);
|
static std::vector<pointer> getAll(Session& session);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Filters::showDialog()
|
|||||||
{
|
{
|
||||||
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
|
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
|
||||||
|
|
||||||
const auto types {Database::ClusterType::getAll(LmsApp->getDbSession())};
|
const auto types {Database::ClusterType::getAllUsed(LmsApp->getDbSession())};
|
||||||
for (const Database::ClusterType::pointer& type : types)
|
for (const Database::ClusterType::pointer& type : types)
|
||||||
typeCombo->addItem(Wt::WString::fromUTF8(type->getName()));
|
typeCombo->addItem(Wt::WString::fromUTF8(type->getName()));
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,6 @@ testSingleCluster(Session& session)
|
|||||||
{
|
{
|
||||||
auto transaction {session.createUniqueTransaction()};
|
auto transaction {session.createUniqueTransaction()};
|
||||||
|
|
||||||
|
|
||||||
auto clusters {Cluster::getAll(session)};
|
auto clusters {Cluster::getAll(session)};
|
||||||
CHECK(clusters.size() == 1);
|
CHECK(clusters.size() == 1);
|
||||||
CHECK(clusters.front().id() == cluster.getId());
|
CHECK(clusters.front().id() == cluster.getId());
|
||||||
@@ -242,6 +241,10 @@ testSingleCluster(Session& session)
|
|||||||
CHECK(clusterTypes.size() == 1);
|
CHECK(clusterTypes.size() == 1);
|
||||||
CHECK(clusterTypes.front().id() == clusterType.getId());
|
CHECK(clusterTypes.front().id() == clusterType.getId());
|
||||||
|
|
||||||
|
clusterTypes = ClusterType::getAllUsed(session);
|
||||||
|
CHECK(clusterTypes.size() == 1);
|
||||||
|
CHECK(clusterTypes.front().id() == clusterType.getId());
|
||||||
|
|
||||||
clusterTypes = ClusterType::getAllOrphans(session);
|
clusterTypes = ClusterType::getAllOrphans(session);
|
||||||
CHECK(clusterTypes.empty());
|
CHECK(clusterTypes.empty());
|
||||||
}
|
}
|
||||||
@@ -253,6 +256,8 @@ testSingleCluster(Session& session)
|
|||||||
auto clusterTypes {ClusterType::getAllOrphans(session)};
|
auto clusterTypes {ClusterType::getAllOrphans(session)};
|
||||||
CHECK(clusterTypes.size() == 1);
|
CHECK(clusterTypes.size() == 1);
|
||||||
CHECK(clusterTypes.front().id() == clusterType.getId());
|
CHECK(clusterTypes.front().id() == clusterType.getId());
|
||||||
|
|
||||||
|
CHECK(ClusterType::getAllUsed(session).empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user