{{project.desc}}
+ {% if editable %} + + {% endif %} +diff --git a/module/form.py b/module/form.py
index 1860b677..5a9d2ddb 100644
--- a/module/form.py
+++ b/module/form.py
@@ -262,6 +262,27 @@ def all_clothes(pid: str) -> Generator[dict[str, Any], None, None]:
'''
yield from FormDB().find({'case': 'clothes', 'pid': pid})
+ @staticmethod
+ def get_clothes_statistics(pid: str) -> dict[str, int]:
+ ''' Get clothes statistics by given pid '''
+ result = {
+ 'XS': 0,
+ 'S': 0,
+ 'M': 0,
+ 'L': 0,
+ 'XL': 0,
+ '2XL': 0,
+ '3XL': 0,
+ '4XL': 0,
+ '5XL': 0,
+ '6XL': 0,
+ }
+
+ for form in Form.all_clothes(pid=pid):
+ result[form['data']['clothes']] += 1
+
+ return result
+
@staticmethod
def update_parking_card(pid: str, uid: str, data: dict[str, Any]) -> dict[str, Any]:
''' Update parking card
@@ -429,6 +450,19 @@ def get(pid: str) -> Generator[dict[str, Any], None, None]:
'''
yield from FormDB().find({'case': 'accommodation', 'pid': pid, 'data.key': {'$ne': 'no'}})
+ @staticmethod
+ def get_statistics(pid: str) -> dict[str, int]:
+ ''' Get accommodation statistics by given pid '''
+ result = {
+ 'yes': 0,
+ 'yes-longtraffic': 0,
+ }
+
+ for form in FormAccommodation.get(pid=pid):
+ result[form['data']['key']] += 1
+
+ return result
+
@staticmethod
def update_room(pid: str, uid: str, room: str, change_key: bool = True) -> dict[str, Any]:
''' Update room no
diff --git a/module/users.py b/module/users.py
index 91667c1b..00a132cb 100644
--- a/module/users.py
+++ b/module/users.py
@@ -7,7 +7,7 @@
from models.oauth_db import OAuthDB
from models.users_db import PolicySignedDB, TobeVolunteerDB, UsersDB
-from module.dietary_habit import DietaryHabitItemsValue
+from module.dietary_habit import DietaryHabitItemsName, DietaryHabitItemsValue
from module.mattermost_bot import MattermostTools
from module.skill import TobeVolunteerStruct
from structs.users import PolicyType
@@ -425,6 +425,26 @@ def marshal_dietary_habit(user_infos: dict[str, Any]) -> Generator[dict[str, Any
yield data
+ @staticmethod
+ def get_dietary_habit_statistics(uids: list[str]) -> dict[str, int]:
+ ''' Get dietary habit statistics by given uids '''
+ result: dict[str, int] = { }
+
+ for item in DietaryHabitItemsName:
+ result[item.value] = 0
+
+ user_infos = User.get_info(uids=uids)
+ for user_info in user_infos.values():
+ if "profile_real" not in user_info or \
+ "dietary_habit" not in user_info["profile_real"]:
+ continue
+
+ for habit in user_info["profile_real"]["dietary_habit"]:
+ habit_enum_name = DietaryHabitItemsValue(habit).name
+ result[DietaryHabitItemsName[habit_enum_name].value] += 1
+
+ return result
+
class TobeVolunteer:
''' TobeVolunteer '''
diff --git a/templates/project_statistics.html b/templates/project_statistics.html
new file mode 100644
index 00000000..c1a9235f
--- /dev/null
+++ b/templates/project_statistics.html
@@ -0,0 +1,91 @@
+{% extends "base.html" %}
+{% block head_title %}{{project.name}} 統計資訊{% endblock %}
+{% block body %}
+ {{project.desc}}
+ {{project.name}}
+
+ 飲食習慣人數分布
+
+
+
+ 習慣
+ 人數
+
+
+ {% for habit, count in habit_statistics.items() %}
+
+
+ {% endfor %}
+
+ {{ habit }}
+ {{ count }}
+ 衣服尺寸人數分布
+
+
+
+ 尺寸
+ 人數
+
+
+ {% for clothes_size, count in clothes_statistics.items() %}
+
+
+ {% endfor %}
+
+ {{ clothes_size }}
+ {{ count }}
+ 住宿人數
+
+
+
+ 住宿選項
+ 人數
+
+
+ {% for accmmodation_option, count in accommodation_statictics.items() %}
+ {% if accmmodation_option == 'yes' %}
+
+
+ {% elif accmmodation_option == 'yes-longtraffic' %}
+ 需要住宿
+ {{ count }}
+
+
+ {% endif %}
+ {% endfor %}
+
+ 需要住宿,且通勤時間大於一小時
+ {{ count }}
+
總人數:{{total}}