From 200ce040b05e76f2d0fd3eaa77bd35a7d00a4b79 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 7 Apr 2023 18:25:21 +0100 Subject: Simplified/faster sitemap generation --- gentoobrowse/src/mash.ice | 14 -------------- gentoobrowse/src/search.cpp | 19 ++++++------------- gentoobrowse/xslt/sitemap.xslt | 7 ++++--- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/gentoobrowse/src/mash.ice b/gentoobrowse/src/mash.ice index 0ed9f76..abdcec1 100644 --- a/gentoobrowse/src/mash.ice +++ b/gentoobrowse/src/mash.ice @@ -24,15 +24,6 @@ module GentooBrowse { ["slicer:key:timestamp","slicer:value:categories","slicer:item:sync"] dictionary Syncs; - - struct SiteMapCategory { - ["slicer:name:detail"] - Gentoo::OverviewCategory category; - Gentoo::Packages packages; - }; - - ["slicer:element:category"] - sequence SiteMapCategories; }; ["slicer:root:gentoo"] @@ -56,11 +47,6 @@ module GentooBrowse { Gentoo::Ebuilds versions; }; - ["slicer:root:gentoo"] - class Sitemap extends PageBase { - Wrappers::SiteMapCategories categories; - }; - ["slicer:root:gentoo"] class Search extends PageBase { Gentoo::Categories categories; diff --git a/gentoobrowse/src/search.cpp b/gentoobrowse/src/search.cpp index 52a5846..93ce80f 100644 --- a/gentoobrowse/src/search.cpp +++ b/gentoobrowse/src/search.cpp @@ -36,20 +36,13 @@ namespace GentooBrowse { { auto _ar_categories = prx0->getAllOverviewCategoriesAsync(request->getContext()); auto _ar_packages = prx0->getAllPackagesAsync(request->getContext()); - ::GentooBrowse::SitemapPtr _responseModel = std::make_shared<::GentooBrowse::Sitemap>(); + auto _responseModel = std::make_shared(); auto categories = _ar_categories.get(); - auto packages = _ar_packages.get(); - for (const auto & super : categories) { - std::transform(super.second.begin(), super.second.end(), - std::inserter(_responseModel->categories, _responseModel->categories.begin()), - [&packages](auto c) { - Gentoo::Packages ps; - std::copy_if(packages.begin(), packages.end(), std::inserter(ps, ps.begin()), [&c](auto p) { - return p->categoryid == c->categoryid; - }); - return GentooBrowse::Wrappers::SiteMapCategory({c, ps}); - }); - } + std::for_each(categories.begin(), categories.end(), + [ins = std::back_inserter(_responseModel->categories)](auto && oc) { + std::move(oc.second.begin(), oc.second.end(), ins); + }); + _responseModel->packages = _ar_packages.get(); request->response(this, _responseModel); } diff --git a/gentoobrowse/xslt/sitemap.xslt b/gentoobrowse/xslt/sitemap.xslt index 055b48d..40fa765 100644 --- a/gentoobrowse/xslt/sitemap.xslt +++ b/gentoobrowse/xslt/sitemap.xslt @@ -2,6 +2,7 @@ https://gentoobrowse.randomdan.homeip.net/ + @@ -17,8 +18,8 @@ weekly - - + + packages/ @@ -26,7 +27,7 @@ daily - + packages// -- cgit v1.2.3