diff --git a/src/layui/layui/rdbMarkerBrowserPage.cc b/src/layui/layui/rdbMarkerBrowserPage.cc index 173f20739..7d9625053 100644 --- a/src/layui/layui/rdbMarkerBrowserPage.cc +++ b/src/layui/layui/rdbMarkerBrowserPage.cc @@ -806,25 +806,43 @@ private: size_t num_waived_per_cat (id_type cat_id) const { - auto ii = mp_database->items_by_category (cat_id); size_t n = 0; + + auto ii = mp_database->items_by_category (cat_id); for (auto i = ii.first; i != ii.second; ++i) { if ((*i)->has_tag (m_waived_tag_id)) { ++n; } } + + // include sub-categories + const rdb::Category *cat = mp_database->category_by_id (cat_id); + tl_assert (cat != 0); + for (auto c = cat->sub_categories ().begin (); c != cat->sub_categories ().end (); ++c) { + n += num_waived_per_cat (c->id ()); + } + return n; } size_t num_waived_per_cell_and_cat (id_type cell_id, id_type cat_id) const { - auto ii = mp_database->items_by_cell_and_category (cell_id, cat_id); size_t n = 0; + + auto ii = mp_database->items_by_cell_and_category (cell_id, cat_id); for (auto i = ii.first; i != ii.second; ++i) { if ((*i)->has_tag (m_waived_tag_id)) { ++n; } } + + // include sub-categories + const rdb::Category *cat = mp_database->category_by_id (cat_id); + tl_assert (cat != 0); + for (auto c = cat->sub_categories ().begin (); c != cat->sub_categories ().end (); ++c) { + n += num_waived_per_cell_and_cat (cell_id, c->id ()); + } + return n; } diff --git a/src/rdb/rdb/rdb.cc b/src/rdb/rdb/rdb.cc index b3ea21a41..b1e41866c 100644 --- a/src/rdb/rdb/rdb.cc +++ b/src/rdb/rdb/rdb.cc @@ -1868,6 +1868,18 @@ namespace }; } +static void map_category (const rdb::Category &cat, const rdb::Database &db, std::map &cat2cat) +{ + const rdb::Category *this_cat = db.category_by_name (cat.path ()); + if (this_cat) { + cat2cat.insert (std::make_pair (this_cat->id (), cat.id ())); + } + + for (auto c = cat.sub_categories ().begin (); c != cat.sub_categories ().end (); ++c) { + map_category (*c, db, cat2cat); + } +} + void Database::apply (const rdb::Database &other) { @@ -1886,10 +1898,7 @@ Database::apply (const rdb::Database &other) } for (auto c = other.categories ().begin (); c != other.categories ().end (); ++c) { - const rdb::Category *this_cat = category_by_name (c->path ()); - if (this_cat) { - cat2cat.insert (std::make_pair (this_cat->id (), c->id ())); - } + map_category (*c, *this, cat2cat); } std::map tags_by_name;