matcher

package
v1.0.31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheTree

func CacheTree(id *primitive.ObjectID, bytes []byte) error

CacheTree caches a tree

func NukeCache

func NukeCache() error

NukeCache well the name explains itself it clears the complete cache

func ObtainCachedTree

func ObtainCachedTree(id *primitive.ObjectID) (fs.FileInfo, *os.File, error)

ObtainCachedTree might return a cached tree

Types

type AddLeafProps

type AddLeafProps struct {
	Titles    []string  `json:"titles"`
	TitleKind TitleKind `json:"titleKind"`
}

AddLeafProps are the leaf creation arguments for the AddLeaf method

type Branch

type Branch struct {
	db.M `bson:",inline"`

	// The titles of this branch
	// At least one title should be set
	Titles []string `bson:"title" json:"titles,omitempty"`

	// The kind of title
	// In the data we import there are 2 kinds of titles
	// One that contains a job name
	// And one that contains a Sector name
	TitleKind TitleKind `bson:"titleKind" json:"titleKind"`

	// Branches contains sub branches ontop of this branch
	Branches []primitive.ObjectID `json:"branchesIds,omitempty"`

	// ParsedBranches can be set when building a tree that is send to a user over the api in JSON format
	ParsedBranches []*Branch `bson:"-" json:"branches,omitempty"`

	// Used by the tree to find the root branches
	HasParents bool `json:"-" bson:"-"`
}

Branch contains a branch of the matcher tree

func FindParents

func FindParents(dbConn db.Connection, id primitive.ObjectID) ([]Branch, error)

FindParents find the branchs that have the id arg as parent

func GetBranch

func GetBranch(dbConn db.Connection, id primitive.ObjectID) (*Branch, error)

GetBranch fetches a spesific branch from the database

func (*Branch) AddLeaf

func (b *Branch) AddLeaf(dbConn db.Connection, props AddLeafProps, injectIntoSource bool) (*Branch, error)

AddLeaf adds a new branch to

func (*Branch) CollectionName

func (*Branch) CollectionName() string

CollectionName implements db.Entry

func (*Branch) Indexes

func (*Branch) Indexes() []mongo.IndexModel

Indexes implements db.Entry

func (*Branch) Update

func (b *Branch) Update(dbConn db.Connection, props AddLeafProps) error

Update updates a spesific branches data

type TitleKind

type TitleKind uint8

TitleKind defines the kind of the title

const (
	// Job name
	Job TitleKind = iota
	// Sector name
	Sector
	// Education name
	Education
	// Root of the tree
	Root
)

func (TitleKind) JSONSchemaDescribe

func (TitleKind) JSONSchemaDescribe() jsonschema.Property

JSONSchemaDescribe implements jsonschema.Describe

func (TitleKind) Valid

func (k TitleKind) Valid() error

Valid returns an error if the tree is valid

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree contains the cache for the tree so tree resolution can be fast

func (*Tree) GetBranch

func (tc *Tree) GetBranch(dbConn db.Connection, branchID *primitive.ObjectID) (*Branch, error)

GetBranch returns a branch with all the child branches in a tree structure

func (*Tree) GetIDsForBranch

func (tc *Tree) GetIDsForBranch(dbConn db.Connection, branchID primitive.ObjectID) ([]primitive.ObjectID, error)

GetIDsForBranch returns a spesific branches child branches their ids

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL