fix: Filters from list and regex both match (#2)
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
763359c3d6
commit
9cff851021
6 changed files with 254 additions and 41 deletions
|
|
@ -60,3 +60,21 @@ func (s *Session) IsIdle() bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Equal returns true when two sessions share the same process id
|
||||
func (s *Session) Equal(session *Session) bool {
|
||||
if s.Pid == 0 {
|
||||
return s.User == session.User && s.Db == session.Db && s.Client == session.Client
|
||||
}
|
||||
return s.Pid == session.Pid
|
||||
}
|
||||
|
||||
// InSlice returns true when this sessions in present in the slice
|
||||
func (s *Session) InSlice(sessions []*Session) bool {
|
||||
for _, session := range sessions {
|
||||
if s.Equal(session) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue