module commands_catalog
import commands_model
+import catalog
# A DocCommand based on a Catalog
abstract class CmdCatalog
super DocCommand
+ autoinit(model, catalog, filter)
+
# Catalog to query at
var catalog: Catalog
end
super CmdCatalog
super CmdSearch
- autoinit(view, catalog, query, limit, page, count, max)
+ autoinit(model, catalog, filter, query, limit, page, count, max)
redef fun init_results do
if results != null then return new CmdSuccess
if query == null then return new ErrorNoQuery
sorter = null
- var index = view.index
+ var filter = self.filter
+ var index = model.index
# lookup by name prefix
- var matches = index.find_by_name_prefix(query).uniq.
+ var matches = index.find_by_name_prefix(query, filter).uniq.
sort(lname_sorter, name_sorter, kind_sorter)
matches = matches.rerank.sort(vis_sorter, score_sorter)
var malus = matches.length
if catalog.tag2proj.has_key(query) then
for mpackage in catalog.tag2proj[query] do
+ if filter != null and not filter.accept_mentity(mpackage) then continue
matches.add new IndexMatch(mpackage, malus)
malus += 1
end
# lookup by full_name prefix
malus = matches.length
var full_matches = new IndexMatches
- for match in index.find_by_full_name_prefix(query).
+ for match in index.find_by_full_name_prefix(query, filter).
sort(lfname_sorter, fname_sorter) do
match.score += 1
full_matches.add match
# lookup by similarity
malus = matches.length
var sim_matches = new IndexMatches
- for match in index.find_by_similarity(query).sort(score_sorter, lname_sorter, name_sorter) do
+ for match in index.find_by_similarity(query, filter).sort(score_sorter, kind_sorter, lname_sorter, name_sorter) do
if match.score > query.length then break
match.score += 1
sim_matches.add match
super CmdCatalog
super CmdEntities
- autoinit(view, catalog, limit, page, count, max)
+ autoinit(model, catalog, filter, limit, page, count, max)
redef var sorter = new CatalogScoreSorter(catalog) is lazy
class CmdCatalogTag
super CmdCatalogPackages
- autoinit(view, catalog, tag, limit, page, count, max)
+ autoinit(model, catalog, filter, tag, limit, page, count, max)
# The tag to retrieve
var tag: nullable String = null is optional, writable
super CmdCatalogPerson
super CmdCatalogPackages
- autoinit(view, catalog, person, person_name, limit, page, count, max)
+ autoinit(model, catalog, filter, person, person_name, limit, page, count, max)
redef fun init_command do return super
super CmdCatalogPerson
super CmdCatalogPackages
- autoinit(view, catalog, person, person_name, limit, page, count, max)
+ autoinit(model, catalog, filter, person, person_name, limit, page, count, max)
# Include maintained packages?
#