<commit_before>class ProfileController < ApplicationController

    def myprofile
        @user = current_user
    
        #Badges earned by this user
        @sprint_badges = @user.sprint_badges.group_by(&:badge).map { |key,value| {key => value.size} }

        @sprints = current_user.group.sprints # can be empty if the user doesn't have any sprints and cause a bug(need to address this)

        @max_total_points, @max_student_points = 0, 0
        @data = []
        @data_point_comparative = []

        if @sprints.length > 0
          @sprint = params[:sprint_id].present? ? Sprint.find(params[:sprint_id]) : @sprints.first

          # we need this in case if a AJAX request is received
          @sprint_index = @sprints.index(@sprint) + 1

          @maximum_points = capitalize_page_type(@sprint.total_points) # can be an empty array
          @student_points = @sprint.student_points(current_user.id)
          @student_points = capitalize_page_type(@student_points) # can be an empty array

          # If the second array's size is less than the first, nil values are supplied
          # For more, see http://apidock.com/ruby/Array/zip

          if !@maximum_points.empty? and @maximum_points.length == @student_points.length
            @data = @maximum_points.zip(@student_points).map { |arr|
              { name: arr.first.first,
                y: arr.first.last,
                student_marks: arr.last.last
              }
            }

            @max_total_points = sum_points(@data, :y)
            @max_student_points = sum_points(@data, :student_marks)
            @avg_students_points = @sprint.avg_classroom_points

          end
        end

        respond_to do |format|
          format.html
          format.js
        end
    end
<commit_msg>Fix display of maximum total score<commit_after>class ProfileController < ApplicationController

    def myprofile
        @user = current_user
    
        #Badges earned by this user
        @sprint_badges = @user.sprint_badges.group_by(&:badge).map { |key,value| {key => value.size} }

        @sprints = current_user.group.sprints # can be empty if the user doesn't have any sprints

        @max_total_points, @max_student_points = 0, 0
        @data = []
        @data_point_comparative = []

        if @sprints.length > 0
          @sprint = params[:sprint_id].present? ? Sprint.find(params[:sprint_id]) : @sprints.first

          # we need this in case if a AJAX request is received
          @sprint_index = @sprints.index(@sprint) + 1

          @maximum_points = capitalize_page_type(@sprint.total_points) # can be an empty array
          @student_points = @sprint.student_points(current_user.id)
          @student_points = capitalize_page_type(@student_points) # can be an empty array

          @max_total_points = @maximum_points.flatten.reject {|e| !e.is_a? Integer}.sum

          # If the second array's size is less than the first, nil values are supplied
          # For more, see http://apidock.com/ruby/Array/zip

          if !@maximum_points.empty? and @maximum_points.length == @student_points.length
            @data = @maximum_points.zip(@student_points).map { |arr|
              { name: arr.first.first,
                y: arr.first.last,
                student_marks: arr.last.last
              }
            }

            @max_total_points = sum_points(@data, :y)
            @max_student_points = sum_points(@data, :student_marks)
            @avg_students_points = @sprint.avg_classroom_points

          end
        end

        respond_to do |format|
          format.html
          format.js
        end
    end

{'fraction_non_alphanumeric': 0.094282572842221, 'fraction_numerical': 0.0021990104452996153, 'mean_word_length': 2.249107142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '958427', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1055, 'n_words': 259}