filter

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Default event name similarity if one not specified
	DefaultEventNameSimilarity = 0.9
)

Variables

This section is empty.

Functions

func FilterTicketListings

func FilterTicketListings(
	listings []twigots.TicketListing,
	predicates ...TicketListingPredicate,
) []twigots.TicketListing

FilterTicketListings filters ticket listings to those that satisfy all of the provided predicates.

If no predicates are provided, all listings are returned.

func TicketListingMatchesAllPredicates

func TicketListingMatchesAllPredicates(listing twigots.TicketListing, predicates ...TicketListingPredicate) bool

TicketListingMatchesAllPredicates checks whether a ticket listing satisfies all of the predicates provided.

Returns true if no predicates are provided.

func TicketListingMatchesAnyPredicate

func TicketListingMatchesAnyPredicate(listing twigots.TicketListing, predicates ...TicketListingPredicate) bool

TicketListingMatchesAnyPredicate checks whether a ticket listing satisfies any of the predicates provided.

Returns false if no predicates are provided.

Types

type TicketListingPredicate

type TicketListingPredicate func(twigots.TicketListing) bool

TicketListingPredicate is a predicate function that evaluates a TicketListing and returns whether or not the listing satisfies a condition.

func CreatedAfter

func CreatedAfter(createdAfter time.Time) TicketListingPredicate

CreatedAfter creates a predicate that matches ticket listings created after the specified time.

If createdAfter is zero time, any creation time will match.

func CreatedBefore

func CreatedBefore(createdBefore time.Time) TicketListingPredicate

CreatedBefore creates a predicate that matches ticket listings created before the specified time.

If createdBefore is zero time, any creation time will match.

func EventName

func EventName(eventName string, minimumSimilarity float64) TicketListingPredicate

EventRegionIn creates a predicate that matches ticket listings with an event name matching the one specified.

Similarity is a float between 0 and 1 (with 0 represent ing no similarity and 1 representing an exact match).

Set minimumSimilarity to <=0 to use the default of 0.9 which allows for minor variances in event names.

If eventName is empty, any event name will match.

If minimumSimilarity is set to >1, minimumSimilarity will be set to 1 (exact match only).

func EventRegion

func EventRegion(regions ...twigots.Region) TicketListingPredicate

EventRegion creates a predicate that matches ticket listings with an event in any of the specified regions.

Invalid regions will be ignored.

If regions is empty, or all regions are invali,d any region will match.

func MaxTicketPriceInclFee added in v0.5.0

func MaxTicketPriceInclFee(maxPrice float64) TicketListingPredicate

MaxTicketPriceInclFee creates a predicate that matches ticket listings with a price incl fee below the specified max.

Set maxPrice to <=0 to match any price.

func MinDiscount

func MinDiscount(minDiscount float64) TicketListingPredicate

MinDiscount creates a predicate that matches ticket listings with a discount above the specified min.

Discount is specified as a float, between 0 and 1 (with 0 representing no discount and 1 representing 100% off).

Set minDiscount to <=0 to match any discount (including no discount).

If minDiscount is set to >1, minDiscount will be set to 1 (100% discount only).

func NumTickets

func NumTickets(numTickets int) TicketListingPredicate

NumTickets creates a predicate that matches ticket listings with the specified number of tickets.

Set numTickets to <=0 to match any number of tickets.

Jump to

Keyboard shortcuts

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