From 680a6e4e364c02d728c805fb126b536248ad3b67 Mon Sep 17 00:00:00 2001 From: Peppa Date: Fri, 20 Nov 2026 09:04:22 +0500 Subject: [PATCH] =?UTF-8?q?IA-3:=20=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D1=81=D0=B2=D0=BE=D0=B4=D0=BA=D1=83=20=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=D0=B4=D0=BD=D0=B8=D0=B5=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D1=81=D0=B0=D0=B9=D1=82=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/glossary.md | 1 + hunter/locales/en.json | 8 ++++ hunter/locales/kk.json | 8 ++++ hunter/locales/ru.json | 8 ++++ hunter/templates/competitors.html | 37 ++++++++++++++++++- hunter/web.py | 20 +++++++++- .../changes/ia-3-competitor-summary/tasks.md | 2 +- 7 files changed, 81 insertions(+), 3 deletions(-) diff --git a/docs/glossary.md b/docs/glossary.md index 4a636e1..9692595 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -26,3 +26,4 @@ | Запланированное событие | встреча | ивент | Запись в Google Календаре | | Онлайн-встреча | видеозвонок, Google Meet | конференц-сессия | Ссылка для подключения к встрече | | Расписание встреч | Google Календарь | Calendar API | Сервис, в который добавляется встреча | +| Наблюдение за сайтами компаний | мониторинг конкурентов, сводка по конкурентам | конкурентная разведка | Состояние добавленных сайтов и изменения, обнаруженные при обновлении | diff --git a/hunter/locales/en.json b/hunter/locales/en.json index 87b8d4d..2526ab6 100644 --- a/hunter/locales/en.json +++ b/hunter/locales/en.json @@ -102,6 +102,14 @@ "export_excel": "Download Excel", "export_pdf": "Download PDF", "competitors_hint": "Add an official company website. Changes appear on subsequent updates after the initial snapshot.", + "competitor_summary": "Competitor summary", + "monitored_sites": "Sites monitored", + "sites_pending": "Awaiting an update", + "sites_failed": "Update failed", + "sites_changed": "Changes detected in the last 7 days", + "no_monitored_sites": "No sites have been added yet.", + "last_detected_change": "Last detected change", + "no_detected_changes": "No changes detected yet.", "company": "Company", "website": "Official website", "add": "Add", diff --git a/hunter/locales/kk.json b/hunter/locales/kk.json index 61c8a58..2468392 100644 --- a/hunter/locales/kk.json +++ b/hunter/locales/kk.json @@ -102,6 +102,14 @@ "export_excel": "Excel жүктеу", "export_pdf": "PDF жүктеу", "competitors_hint": "Компанияның ресми сайтын қосыңыз. Алғашқы түсірілімнен кейінгі жаңартуларда өзгерістерді көресіз.", + "competitor_summary": "Бәсекелестер туралы шолу", + "monitored_sites": "Бақылаудағы сайттар", + "sites_pending": "Жаңартуды күтуде", + "sites_failed": "Жаңарту сәтсіз аяқталды", + "sites_changed": "7 тәулікте өзгеріс анықталды", + "no_monitored_sites": "Сайттар әлі қосылмаған.", + "last_detected_change": "Соңғы анықталған өзгеріс", + "no_detected_changes": "Әзірге өзгерістер анықталған жоқ.", "company": "Компания", "website": "Ресми сайт", "add": "Қосу", diff --git a/hunter/locales/ru.json b/hunter/locales/ru.json index 3a8fc79..a56b2e2 100644 --- a/hunter/locales/ru.json +++ b/hunter/locales/ru.json @@ -102,6 +102,14 @@ "export_excel": "Скачать Excel", "export_pdf": "Скачать PDF", "competitors_hint": "Добавьте официальный сайт компании. После первого снимка вы увидите обнаруженные изменения при следующих обновлениях.", + "competitor_summary": "Сводка по конкурентам", + "monitored_sites": "Отслеживаемые сайты", + "sites_pending": "Ждут обновления", + "sites_failed": "С ошибкой обновления", + "sites_changed": "С изменениями за 7 суток", + "no_monitored_sites": "Сайты ещё не добавлены.", + "last_detected_change": "Последнее обнаруженное изменение", + "no_detected_changes": "Изменения пока не обнаружены.", "company": "Компания", "website": "Официальный сайт", "add": "Добавить", diff --git a/hunter/templates/competitors.html b/hunter/templates/competitors.html index 94ec801..9fe5431 100644 --- a/hunter/templates/competitors.html +++ b/hunter/templates/competitors.html @@ -1,5 +1,40 @@ {% extends 'base.html' %}{% from 'macros.html' import page_header,empty with context %} {% block content %}{{ page_header(t('competitors'),t('competitors_hint')) }} +
+

{{ t('competitor_summary') }}

+ {% if companies %} +
+ {% for label, value in summary.items() %} +
+
{{ t(label) }}
+ {{ value }} +
+ {% endfor %} +
+ {% else %} +

{{ t('no_monitored_sites') }}

+ {% endif %} +
{% if user.role in ['admin','analyst'] %}
{% endif %} -
{% for company in companies %}
{{ company.name[0] }}

{{ company.name }}

{{ t('website') }} ↗

{{ t(company.status) }}

{{ t('last_update') }}: {{ company.updated[:16]|replace('T',' ') if company.updated else t('date_unknown') }} UTC
{% else %}{{ empty() }}{% endfor %}

{{ t('alerts') }}

+{% if companies %} +
+ {% for company in companies %} +
+
{{ company.name[0] }}
+

{{ company.name }}

+ {{ t('website') }} ↗ +

{{ t(company.status) }}

+ {{ t('last_update') }}: {% if company.updated %}{{ company.updated[:16]|replace('T',' ') }} UTC{% else %}{{ t('date_unknown') }}{% endif %} +

+ {% if company.last_change %} + {{ t('last_detected_change') }}: + {% else %} + {{ t('no_detected_changes') }} + {% endif %} +

+
+ {% endfor %} +
+{% endif %} +

{{ t('alerts') }}

{% for item in changes %}

{{ item.name }}

{{ day(item.created) }}

{{ t('change') }}

{{ t('change_hint') }}

{{ t('why_important') }}

{{ t('hypothesis') }}

{{ t('reaction') }}

{{ t('reaction_hint') }}

{{ t('original') }} ↗
{{ t('details') }}

{{ t('previous') }}

{{ item.previous }}

{{ t('current') }}

{{ item.current }}

{% else %}{{ empty() }}{% endfor %}{% endblock %} diff --git a/hunter/web.py b/hunter/web.py index bb4153c..9a98cad 100644 --- a/hunter/web.py +++ b/hunter/web.py @@ -442,10 +442,28 @@ def competitors(): except (ValueError, OSError, sqlite3.IntegrityError): flash(g.t("invalid"), "error") return redirect(url_for("web.competitors")) + companies = rows( + """ + SELECT p.name, p.url, p.status, p.updated, recent.last_change + FROM companies p + LEFT JOIN ( + SELECT company_id, MAX(created) AS last_change FROM changes GROUP BY company_id + ) recent ON recent.company_id = p.id + ORDER BY p.name + """ + ) + cutoff = (datetime.now(timezone.utc) - timedelta(days=7)).isoformat(timespec="seconds") + summary = { + "monitored_sites": len(companies), + "sites_pending": sum(company["status"] == "pending" for company in companies), + "sites_failed": sum(company["status"] == "error" for company in companies), + "sites_changed": sum((company["last_change"] or "") >= cutoff for company in companies), + } return render_template( "competitors.html", page="competitors", - companies=rows("SELECT * FROM companies ORDER BY name"), + companies=companies, + summary=summary, changes=rows( "SELECT c.*,p.name,p.url FROM changes c JOIN companies p ON c.company_id=p.id ORDER BY c.id DESC LIMIT 50" ), diff --git a/openspec/changes/ia-3-competitor-summary/tasks.md b/openspec/changes/ia-3-competitor-summary/tasks.md index be121c6..d4835b0 100644 --- a/openspec/changes/ia-3-competitor-summary/tasks.md +++ b/openspec/changes/ia-3-competitor-summary/tasks.md @@ -2,5 +2,5 @@ ## 1. Сводка -- [ ] 1.1 Добавить сводку и дату последнего изменения на экран мониторинга с переводами и сверкой по словарю. +- [x] 1.1 Добавить сводку и дату последнего изменения на экран мониторинга с переводами и сверкой по словарю. - [ ] 1.2 Проверить сводку на заполненном и пустом экране, запустить проверки проекта и `openspec validate`.