<commit_before>package models

import "errors"

type Datastore interface {
	GetApp(appName string) (*App, error)
	GetApps(*AppFilter) ([]*App, error)
	StoreApp(*App) (*App, error)
	RemoveApp(appName string) error

	GetRoute(appName, routePath string) (*Route, error)
	GetRoutes(*RouteFilter) (routes []*Route, err error)
	GetRoutesByApp(string, *RouteFilter) (routes []*Route, err error)
	StoreRoute(*Route) (*Route, error)
	RemoveRoute(appName, routePath string) error

	// The following provide a generic key value store for arbitrary data, can be used by extensions to store extra data
	// todo: should we namespace these by app? Then when an app is deleted, it can delete any of this extra data too.
	Put([]byte, []byte) error
	Get([]byte) ([]byte, error)
}

var (
	ErrDatastoreEmptyAppName   = errors.New("Missing app name")
	ErrDatastoreEmptyRoutePath = errors.New("Missing route name")
	ErrDatastoreEmptyApp       = errors.New("Missing app")
	ErrDatastoreEmptyRoute     = errors.New("Missing route")
)

func ApplyAppFilter(app *App, filter *AppFilter) bool {
	return true
}

func ApplyRouteFilter(route *Route, filter *RouteFilter) bool {
	return (filter.Path == "" || route.Path == filter.Path) &&
		(filter.AppName == "" || route.AppName == filter.AppName) &&
		(filter.Image == "" || route.Image == filter.Image)
}<commit_msg>remove unused ApplyAppFilter which always returns true (#177)<commit_after>package models

import "errors"

type Datastore interface {
	GetApp(appName string) (*App, error)
	GetApps(*AppFilter) ([]*App, error)
	StoreApp(*App) (*App, error)
	RemoveApp(appName string) error

	GetRoute(appName, routePath string) (*Route, error)
	GetRoutes(*RouteFilter) (routes []*Route, err error)
	GetRoutesByApp(string, *RouteFilter) (routes []*Route, err error)
	StoreRoute(*Route) (*Route, error)
	RemoveRoute(appName, routePath string) error

	// The following provide a generic key value store for arbitrary data, can be used by extensions to store extra data
	// todo: should we namespace these by app? Then when an app is deleted, it can delete any of this extra data too.
	Put([]byte, []byte) error
	Get([]byte) ([]byte, error)
}

var (
	ErrDatastoreEmptyAppName   = errors.New("Missing app name")
	ErrDatastoreEmptyRoutePath = errors.New("Missing route name")
	ErrDatastoreEmptyApp       = errors.New("Missing app")
	ErrDatastoreEmptyRoute     = errors.New("Missing route")
)

func ApplyRouteFilter(route *Route, filter *RouteFilter) bool {
	return (filter.Path == "" || route.Path == filter.Path) &&
		(filter.AppName == "" || route.AppName == filter.AppName) &&
		(filter.Image == "" || route.Image == filter.Image)
}
{'fraction_non_alphanumeric': 0.13066465256797583, 'fraction_numerical': 0.0011329305135951663, 'mean_word_length': 5.160465116279069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2846745', 'n_tokens_mistral': 827, 'n_tokens_neox': 815, 'n_words': 259}