Coverage for /home/runner/work/viur-core/viur-core/viur/src/viur/core/bones/sortindex.py: 88%

8 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-03 12:27 +0000

1import typing as t 

2import time 

3 

4from viur.core.bones.base import CloneBehavior, CloneStrategy 

5from viur.core.bones.numeric import NumericBone 

6 

7 

8class SortIndexBone(NumericBone): 

9 """ 

10 The SortIndexBone class is specifically designed to handle sorting indexes for data elements, which are 

11 numeric values that determine the order of these elements. It inherits from the NumericBone. 

12 

13 :param int | float defaultValue: A default value for the bone, which is a function that returns 

14 the current time by default. This parameter accepts either an integer or a floating-point number. 

15 :param str descr: A short description of the bone, set to "SortIndex" by default. 

16 :param int precision: The precision of the numeric value, determining the number of decimal places allowed. 

17 The default value is 8. 

18 :param dict kwargs: Additional keyword arguments that can be passed to the parent NumericBone class. 

19 """ 

20 type = "numeric.sortindex" 

21 

22 def __init__( 

23 self, 

24 *, 

25 defaultValue: int | float = lambda *args, **kwargs: time.time(), 

26 descr: str = "SortIndex", 

27 precision: int = 8, 

28 clone_behavior=CloneBehavior(CloneStrategy.SET_DEFAULT), 

29 **kwargs 

30 ): 

31 super().__init__( 

32 defaultValue=defaultValue, 

33 descr=descr, 

34 precision=precision, 

35 clone_behavior=clone_behavior, 

36 **kwargs 

37 )