| 199 | return self._sort_sources(available)[:batch_size] |
| 200 | |
| 201 | def _apply_existing_bonus(self, current_sources: List[Dict], candidate_sources: List[Dict]) -> List[Dict]: |
| 202 | current_urls = {str(item.get("bookSourceUrl", "")).strip() for item in current_sources} |
| 203 | boosted: List[Dict] = [] |
| 204 | for source in candidate_sources: |
| 205 | entry = deepcopy(source) |
| 206 | if str(entry.get("bookSourceUrl", "")).strip() in current_urls: |
| 207 | base = float(entry.get("selectionScore") or entry.get("score") or 0) |
| 208 | entry["selectionScore"] = round(base + 5, 2) |
| 209 | boosted.append(entry) |
| 210 | return boosted |
| 211 | |
| 212 | def build_inventory( |
| 213 | self, |