-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] refactoring of filters (#114)
- Loading branch information
Showing
27 changed files
with
724 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,9 @@ | ||
package all | ||
|
||
import ( | ||
"github.com/FreifunkBremen/yanic/runtime" | ||
_ "github.com/FreifunkBremen/yanic/output/filter/blacklist" | ||
_ "github.com/FreifunkBremen/yanic/output/filter/haslocation" | ||
_ "github.com/FreifunkBremen/yanic/output/filter/inarea" | ||
_ "github.com/FreifunkBremen/yanic/output/filter/noowner" | ||
_ "github.com/FreifunkBremen/yanic/output/filter/site" | ||
) | ||
|
||
// Config Filter | ||
type filterConfig map[string]interface{} | ||
|
||
type filterFunc func(*runtime.Node) *runtime.Node | ||
|
||
func noFilter(node *runtime.Node) *runtime.Node { | ||
return node | ||
} | ||
|
||
// Create Filter | ||
func (f filterConfig) filtering(nodesOrigin *runtime.Nodes) *runtime.Nodes { | ||
nodes := runtime.NewNodes(&runtime.NodesConfig{}) | ||
filterfuncs := []filterFunc{ | ||
f.HasLocation(), | ||
f.Blacklist(), | ||
f.InArea(), | ||
f.NoOwner(), | ||
} | ||
|
||
nodesOrigin.Lock() | ||
defer nodesOrigin.Unlock() | ||
|
||
for _, nodeOrigin := range nodesOrigin.List { | ||
//maybe cloning of this object is better? | ||
node := nodeOrigin | ||
for _, f := range filterfuncs { | ||
node = f(node) | ||
if node == nil { | ||
break | ||
} | ||
} | ||
|
||
if node != nil { | ||
nodes.AddNode(node) | ||
} | ||
} | ||
return nodes | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.