- исправлении логики определения последней версии
This commit is contained in:
22
site_api.py
22
site_api.py
@@ -171,6 +171,8 @@ class SiteAPI:
|
||||
|
||||
numbers = [extract_number(title) for _, title in news_list if extract_number(title) is not None]
|
||||
|
||||
published_versions = set(numbers) if numbers else set()
|
||||
|
||||
if numbers:
|
||||
last_topics_script = max(numbers)
|
||||
self.logger.info(f"Последняя новость на сайте о версии: {last_topics_script}")
|
||||
@@ -182,15 +184,27 @@ class SiteAPI:
|
||||
self.logger.warning("На сайте нет новостей о скриптах")
|
||||
|
||||
# Публикуем новые версии
|
||||
self._publish_new_script_versions(matches_changelog, resp_changelog, content_processor)
|
||||
self._publish_new_script_versions(matches_changelog, published_versions, resp_changelog, content_processor)
|
||||
|
||||
def _publish_new_script_versions(self, matches_changelog, resp_changelog, content_processor):
|
||||
def _publish_new_script_versions(self, matches_changelog, published_versions, resp_changelog, content_processor):
|
||||
"""Публикация новых версий скриптов"""
|
||||
for script_ver, next_version in zip(reversed(matches_changelog[:-1]), reversed(matches_changelog[1:])):
|
||||
# Сортируем версии в порядке возрастания
|
||||
sorted_versions = sorted([int(v) for v in matches_changelog])
|
||||
|
||||
# Проходим по версиям в порядке от старых к новым
|
||||
for i in range(len(sorted_versions) - 1):
|
||||
script_ver = int(sorted_versions[i])
|
||||
next_version = int(sorted_versions[i + 1])
|
||||
|
||||
# Пропускаем уже опубликованные версии
|
||||
if script_ver in published_versions:
|
||||
self.logger.debug(f"Версия скрипта {script_ver} уже опубликована на сайте, пропускаем")
|
||||
continue
|
||||
|
||||
self.logger.info(f"Найдена новая версия скрипта {script_ver}")
|
||||
|
||||
post_text, post_data = self.create_script_update_post(
|
||||
script_ver, next_version, resp_changelog, content_processor
|
||||
str(script_ver), str(next_version), resp_changelog, content_processor
|
||||
)
|
||||
|
||||
if post_data:
|
||||
|
Reference in New Issue
Block a user