File size: 899 Bytes
ca7217f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package dbengine

type ActorSearchOptions struct {
	Provider  string
	Threshold float64
	Limit     int
	Offset    int
}

func (opts *ActorSearchOptions) applyDefaults() {
	const (
		maxLimit  = 20
		threshold = 0.2 // be more tolerated for name search.
	)
	if opts.Threshold == 0 {
		opts.Threshold = threshold
	}
	if opts.Limit > maxLimit {
		opts.Limit = maxLimit
	}
}

type MovieSearchOptions struct {
	Provider   string
	Thresholds MovieThresholds
	Limit      int
	Offset     int
}

type MovieThresholds struct {
	Number float64
	Title  float64
}

func (opts *MovieSearchOptions) applyDefaults() {
	const (
		maxLimit        = 20
		numberThreshold = 0.4
		titleThreshold  = 0.2
	)
	if opts.Thresholds.Number == 0 {
		opts.Thresholds.Number = numberThreshold
	}
	if opts.Thresholds.Title == 0 {
		opts.Thresholds.Title = titleThreshold
	}
	if opts.Limit > maxLimit {
		opts.Limit = maxLimit
	}
}