Class: Searching::GuideProgress::SolvedAssignmentsPercentage

Inherits:
NumericFilter show all
Includes:
QueryOperands
Defined in:
lib/mumuki/classroom/models/searching/guide_progress.rb

Instance Method Summary collapse

Methods included from QueryOperands

#close_to, #default_query_operand, #less_than, #more_than

Methods included from QueryOperands

#current_query_operand, #current_query_operand_method

Methods inherited from NumericFilter

#query_param=

Methods inherited from BaseFilter

#query

Instance Method Details

#pipelineObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/mumuki/classroom/models/searching/guide_progress.rb', line 66

def pipeline
  [
    {
      '$addFields': {
        'stats.solved_percentage': {
          '$multiply': [
            {
              '$divide': [
                {'$sum': %w($stats.passed $stats.passed_with_warnings)},
                {'$sum': %w($stats.passed $stats.passed_with_warnings $stats.failed)}
              ]
            },
            100
          ]
        }
      }
    },
    {
      '$match': {'stats.solved_percentage': current_query_operand }
    }
  ]
end