Coverage for /builds/BuildGrid/buildgrid/buildgrid/server/operations/filtering/filter.py: 100.00%

7 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-06-11 15:37 +0000

1# Copyright (C) 2020 Bloomberg LP 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"); 

4# you may not use this file except in compliance with the License. 

5# You may obtain a copy of the License at 

6# 

7# <http://www.apache.org/licenses/LICENSE-2.0> 

8# 

9# Unless required by applicable law or agreed to in writing, software 

10# distributed under the License is distributed on an "AS IS" BASIS, 

11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

12# See the License for the specific language governing permissions and 

13# limitations under the License. 

14 

15 

16import operator 

17from typing import Any, Callable, NamedTuple 

18 

19from buildgrid._enums import OperationStage 

20 

21OperationFilter = NamedTuple( 

22 "OperationFilter", [("parameter", str), ("operator", Callable[[Any, Any], Any]), ("value", Any)] 

23) 

24 

25 

26DEFAULT_OPERATION_FILTERS = [ 

27 OperationFilter(parameter="stage", operator=operator.ne, value=OperationStage.COMPLETED.value) 

28] 

29 

30SortKey = NamedTuple("SortKey", [("name", str), ("descending", bool)]) 

31 

32DEFAULT_SORT_KEYS = [SortKey(name="queued_time", descending=False), SortKey(name="name", descending=False)]