Reduce SQL queries for tag_statistics

Fixes CODEOCEAN-YP
This commit is contained in:
Sebastian Serth
2023-12-09 00:36:02 +01:00
parent 1bb61f73fe
commit 768eb53f7a
2 changed files with 6 additions and 10 deletions

View File

@ -84,7 +84,7 @@ class ExternalUsersController < ApplicationController
authorize!
statistics = []
tags = ProxyExercise.new.get_user_knowledge_and_max_knowledge(@user, @user.participations.uniq.compact)
tags = ProxyExercise.new.get_user_knowledge_and_max_knowledge(@user, @user.participations.includes(:files, :tags, exercise_tags: [:tag]).uniq.compact)
tags[:user_topic_knowledge].each_pair do |tag, value|
statistics.append({key: tag.name.to_s, value: (100.0 / tags[:max_topic_knowledge][tag] * value).round,
id: tag.id})