CI demo: metrics + Gitea Actions

This commit is contained in:
2026-11-12 13:55:02 +08:00
commit 6637fb8ff4
17 changed files with 564 additions and 0 deletions

35
app/discounts.py Normal file
View File

@@ -0,0 +1,35 @@
"""Скидки демо-проекта ci-demo (СТРПО, неделя 9, Gitea edition)."""
from abc import ABC, abstractmethod
class Discount(ABC):
@abstractmethod
def apply(self, total: float) -> float:
"""Вернуть сумму с учётом скидки."""
class NoDiscount(Discount):
def apply(self, total: float) -> float:
return total
class VIPDiscount(Discount):
def apply(self, total: float) -> float:
return total * 0.9
class EmployeeDiscount(Discount):
def apply(self, total: float) -> float:
return total * 0.7
DISCOUNTS: dict[str, type[Discount]] = {
"regular": NoDiscount,
"vip": VIPDiscount,
"employee": EmployeeDiscount,
}
def discount_for(customer_type: str) -> Discount:
"""Выбрать стратегию скидки по типу клиента."""
return DISCOUNTS.get(customer_type, NoDiscount)()