| Conditions | 4 |
| Total Lines | 23 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | 1 | from collections import OrderedDict |
|
| 21 | def _get_matches(query): |
||
| 22 | items = [] |
||
| 23 | |||
| 24 | for template in app.template_service.all(): |
||
| 25 | count = template.search(query) |
||
| 26 | |||
| 27 | if not count: |
||
| 28 | continue |
||
| 29 | |||
| 30 | data = OrderedDict() |
||
| 31 | data['count'] = count |
||
| 32 | data['template'] = OrderedDict() |
||
| 33 | data['template']['name'] = template.name |
||
| 34 | data['template']['description'] = template.link |
||
| 35 | data['template']['keywords'] = sorted(template.keywords) |
||
| 36 | data['template']['blank'] = route('image.get', key=template.key, |
||
| 37 | path='_', _external=True) |
||
| 38 | data['template']['example'] = route('image.get', key=template.key, |
||
| 39 | path=template.sample_path, |
||
| 40 | _external=True) |
||
| 41 | items.append(data) |
||
| 42 | |||
| 43 | return sorted(items, key=lambda item: item['count'], reverse=True) |
||
| 44 |