aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2018-01-17 09:20:22 -0500
committerAlec Warner <antarus@gentoo.org>2018-01-17 09:20:22 -0500
commit67f12fb04885bc2fd7e4f2369ae74a24aefa159a (patch)
tree4d00828ec9ddd0d64876d58a74f7dd89c509105e /lib
parenthas_parent does not support filter. (diff)
downloadpackages-5-67f12fb04885bc2fd7e4f2369ae74a24aefa159a.tar.gz
packages-5-67f12fb04885bc2fd7e4f2369ae74a24aefa159a.tar.bz2
packages-5-67f12fb04885bc2fd7e4f2369ae74a24aefa159a.zip
Add find_all_by_package.
Due to splitting of indexes for ES6, we can no longer rely on parent, child relations to determine 'which packages have which versions' because ES6 cannot join between two indexes. Instead we lookup in the versions table a particular package (CP). This should yield some reasonable count of versions (typically 1-100). We then use those results to find answers like "highest version" by simplying sorting the result and taking the first of the sort.
Diffstat (limited to 'lib')
-rw-r--r--lib/kkuleomi/store/model.rb14
-rw-r--r--lib/kkuleomi/store/models/package_import.rb2
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/kkuleomi/store/model.rb b/lib/kkuleomi/store/model.rb
index 653884b..23cfcff 100644
--- a/lib/kkuleomi/store/model.rb
+++ b/lib/kkuleomi/store/model.rb
@@ -30,6 +30,20 @@ module Kkuleomi::Store::Model
find_all_by(field, value, opts).first
end
+ def find_all_by_package(package, opts = {})
+ search(opts.merge(
+ size: 10_000,
+ query: {
+ bool: {
+ filter: {
+ term: { package: package } }
+ }
+ },
+ must: { match_all: {} }
+ }
+ ))
+ end
+
def find_all_by_parent(parent, opts = {})
search(opts.merge(
size: 10_000,
diff --git a/lib/kkuleomi/store/models/package_import.rb b/lib/kkuleomi/store/models/package_import.rb
index 3b12d8a..aaeca5c 100644
--- a/lib/kkuleomi/store/models/package_import.rb
+++ b/lib/kkuleomi/store/models/package_import.rb
@@ -103,7 +103,7 @@ module Kkuleomi::Store::Models::PackageImport
end
def import_versions!(package_model, ebuilds, options)
- index_v = Hash[Version.find_all_by_parent(self).map { |v| [v.version, v] }]
+ index_v = Hash[Version.find_all_by_package(self.name).map { |v| [v.version, v] }]
model_v = Hash[ebuilds.map { |v| [v.version, v] }]
index_keys = index_v.keys