Разделил на Positive и Negative
This commit is contained in:
parent
7fddc7a77e
commit
b390ed9c29
@ -72,7 +72,17 @@ class QuestionRepository:
|
||||
@staticmethod
|
||||
async def get_class_statistics() -> dict:
|
||||
async with new_session() as session:
|
||||
query = select(QuestionOrm.answer, func.count(QuestionOrm.id)).group_by(QuestionOrm.answer)
|
||||
query = select(QuestionOrm.type_mood, QuestionOrm.answer, func.count(QuestionOrm.id)).group_by(QuestionOrm.type_mood, QuestionOrm.answer)
|
||||
result = await session.execute(query)
|
||||
statistics = {answer: count for answer, count in result.fetchall()}
|
||||
statistics = {}
|
||||
for row in result.fetchall():
|
||||
mood = row[0]
|
||||
answer = row[1]
|
||||
count = row[2]
|
||||
if mood not in statistics:
|
||||
statistics[mood] = {}
|
||||
if answer not in statistics[mood]:
|
||||
statistics[mood][answer] = count
|
||||
else:
|
||||
statistics[mood][answer] += count
|
||||
return statistics
|
||||
|
Loading…
Reference in New Issue
Block a user