| Conditions | 5 |
| Total Lines | 18 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | # -*- encoding: utf-8 -*- |
||
| 16 | def main(self): |
||
| 17 | self.remove_old_history() |
||
| 18 | rss_list = Rss.select() |
||
| 19 | msg = "" |
||
| 20 | post_url_list = [rss_history.url for rss_history in |
||
| 21 | History.select().where(History.publish_at == datetime.today().strftime("%Y-%m-%d"))] |
||
| 22 | for rss in rss_list: |
||
| 23 | rss_history_list = [] |
||
| 24 | feed = feedparser.parse(rss.feed) |
||
| 25 | for entry in feed.entries: |
||
| 26 | if entry.link not in post_url_list: |
||
| 27 | msg = msg + f"{entry.title}\n{entry.link}\n\n" |
||
| 28 | rss_history_list.append(History(url=entry.link)) |
||
| 29 | |||
| 30 | with db.atomic(): |
||
| 31 | History.bulk_create(rss_history_list, batch_size=10) |
||
| 32 | |||
| 33 | return msg |
||
| 34 | |||
| 45 |