| Conditions | 5 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | """DB client.""" |
||
| 40 | 1 | def bootstrap_index( |
|
| 41 | db: MongoClient, collection: str, index: str, direction: int, **kwargs |
||
| 42 | ) -> Optional[str]: |
||
| 43 | """Bootstrap index.""" |
||
| 44 | 1 | indexes = set() |
|
| 45 | |||
| 46 | 1 | for value in db[collection].index_information().values(): |
|
| 47 | 1 | if "key" in value and isinstance(value["key"], list): |
|
| 48 | 1 | indexes.add(value["key"][0]) |
|
| 49 | |||
| 50 | 1 | if (index, direction) not in indexes: |
|
| 51 | 1 | return db[collection].create_index([(index, direction)], **kwargs) |
|
| 52 | |||
| 53 | return None |
||
| 54 |