IA-3: показать сводку и последние изменения по сайтам
This commit is contained in:
parent
7e86892461
commit
680a6e4e36
@ -26,3 +26,4 @@
|
||||
| Запланированное событие | встреча | ивент | Запись в Google Календаре |
|
||||
| Онлайн-встреча | видеозвонок, Google Meet | конференц-сессия | Ссылка для подключения к встрече |
|
||||
| Расписание встреч | Google Календарь | Calendar API | Сервис, в который добавляется встреча |
|
||||
| Наблюдение за сайтами компаний | мониторинг конкурентов, сводка по конкурентам | конкурентная разведка | Состояние добавленных сайтов и изменения, обнаруженные при обновлении |
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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": "Қосу",
|
||||
|
||||
@ -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": "Добавить",
|
||||
|
||||
@ -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')) }}
|
||||
<section aria-labelledby="competitor-summary">
|
||||
<h2 id="competitor-summary">{{ t('competitor_summary') }}</h2>
|
||||
{% if companies %}
|
||||
<div class="stats-grid">
|
||||
{% for label, value in summary.items() %}
|
||||
<div class="stat-card">
|
||||
<div class="stat-title">{{ t(label) }}</div>
|
||||
<strong class="stat-value">{{ value }}</strong>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="panel">{{ t('no_monitored_sites') }}</p>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% if user.role in ['admin','analyst'] %}<form class="filter-panel panel" method="post"><input type="hidden" name="csrf" value="{{ csrf }}"><label>{{ t('company') }}<input name="name" required maxlength="100"></label><label class="search-label">{{ t('website') }}<input name="url" type="url" required placeholder="{{ t('website_hint') }}"></label><button class="button primary">+ {{ t('add') }}</button></form>{% endif %}
|
||||
<div class="company-grid">{% for company in companies %}<article class="panel company-card"><div class="company-icon">{{ company.name[0] }}</div><h2>{{ company.name }}</h2><a href="{{ company.url }}" target="_blank" rel="noopener noreferrer">{{ t('website') }} ↗</a><p><span class="status-dot {{ company.status }}"></span>{{ t(company.status) }}</p><small>{{ t('last_update') }}: {{ company.updated[:16]|replace('T',' ') if company.updated else t('date_unknown') }} UTC</small></article>{% else %}{{ empty() }}{% endfor %}</div><h2>{{ t('alerts') }}</h2>
|
||||
{% if companies %}
|
||||
<div class="company-grid">
|
||||
{% for company in companies %}
|
||||
<article class="panel company-card">
|
||||
<div class="company-icon">{{ company.name[0] }}</div>
|
||||
<h2>{{ company.name }}</h2>
|
||||
<a href="{{ company.url }}" target="_blank" rel="noopener noreferrer">{{ t('website') }} ↗</a>
|
||||
<p><span class="status-dot {{ company.status }}"></span>{{ t(company.status) }}</p>
|
||||
<small>{{ t('last_update') }}: {% if company.updated %}{{ company.updated[:16]|replace('T',' ') }} UTC{% else %}{{ t('date_unknown') }}{% endif %}</small>
|
||||
<p>
|
||||
{% if company.last_change %}
|
||||
{{ t('last_detected_change') }}: <time datetime="{{ company.last_change }}">{{ day(company.last_change) }}</time>
|
||||
{% else %}
|
||||
{{ t('no_detected_changes') }}
|
||||
{% endif %}
|
||||
</p>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<h2>{{ t('alerts') }}</h2>
|
||||
{% for item in changes %}<article class="panel change-card"><div class="section-heading"><h2>{{ item.name }}</h2><span>{{ day(item.created) }}</span></div><h3>{{ t('change') }}</h3><p>{{ t('change_hint') }}</p><h3>{{ t('why_important') }}</h3><p>{{ t('hypothesis') }}</p><h3>{{ t('reaction') }}</h3><p>{{ t('reaction_hint') }}</p><a href="{{ item.url }}" target="_blank" rel="noopener noreferrer">{{ t('original') }} ↗</a><details><summary>{{ t('details') }}</summary><h4>{{ t('previous') }}</h4><p>{{ item.previous }}</p><h4>{{ t('current') }}</h4><p>{{ item.current }}</p></details></article>{% else %}{{ empty() }}{% endfor %}{% endblock %}
|
||||
|
||||
@ -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"
|
||||
),
|
||||
|
||||
@ -2,5 +2,5 @@
|
||||
|
||||
## 1. Сводка
|
||||
|
||||
- [ ] 1.1 Добавить сводку и дату последнего изменения на экран мониторинга с переводами и сверкой по словарю.
|
||||
- [x] 1.1 Добавить сводку и дату последнего изменения на экран мониторинга с переводами и сверкой по словарю.
|
||||
- [ ] 1.2 Проверить сводку на заполненном и пустом экране, запустить проверки проекта и `openspec validate`.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user