List all posts and their detected subcategories.
(self)
| 238 | json.dump(index_data, f, ensure_ascii=False, indent=2) |
| 239 | |
| 240 | def list_posts(self) -> None: |
| 241 | """List all posts and their detected subcategories.""" |
| 242 | posts = self.get_all_posts() |
| 243 | print(f"\nTotal posts: {len(posts)}\n") |
| 244 | subcategory_counts: Dict[str, int] = {} |
| 245 | for post in posts: |
| 246 | title = self.clean_title(post.get("title", {}).get("rendered", "")) |
| 247 | date = post.get("date", "")[:10] |
| 248 | subcat = self.detect_subcategory(post) |
| 249 | subcategory_counts[subcat] = subcategory_counts.get(subcat, 0) + 1 |
| 250 | print(f" [{date}] [{subcat}] {title[:60]}") |
| 251 | print(f"\nSubcategory distribution:") |
| 252 | for subcat, count in sorted(subcategory_counts.items()): |
| 253 | print(f" {subcat:<30} {count:3d} posts") |
| 254 | |
| 255 | def migrate(self) -> None: |
| 256 | """Main migration entry point.""" |
no test coverage detected