-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
340 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
+PR File |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# maps data and options in review_mapping_charts_helper for relevant methods | ||
module DataMappingHelper | ||
# provide options data for tagging interval chart | ||
def provide_tagging_options | ||
{ | ||
width: '200', | ||
height: '125', | ||
scales: { | ||
yAxes: [{ stacked: false, ticks: { beginAtZero: true } }], | ||
xAxes: [{ stacked: false }] | ||
} | ||
} | ||
end | ||
|
||
# provide volume metric options | ||
def provide_volume_metric_options | ||
{ | ||
legend: { position: 'top', labels: { usePointStyle: true } }, | ||
width: '200', | ||
height: '125', | ||
scales: { | ||
yAxes: [{ stacked: true, id: 'bar-y-axis1', barThickness: 10 }, { display: false, stacked: true, id: 'bar-y-axis2', barThickness: 15, type: 'category', categoryPercentage: 0.8, barPercentage: 0.9, gridLines: { offsetGridLines: true } }], | ||
xAxes: [{ stacked: false, ticks: { beginAtZero: true, stepSize: 50, max: 400 } }] | ||
} | ||
} | ||
end | ||
|
||
# provides data for tagging interval chart | ||
def display_tagging_interval_chart_data(intervals, interval_mean) | ||
{ | ||
labels: [*1..intervals.length], | ||
datasets: [{ backgroundColor: 'rgba(255,99,132,0.8)', data: intervals, label: 'time intervals' }, intervals_check(intervals, interval_mean)] | ||
} | ||
end | ||
|
||
# mapping interval length and mean for display_tagging_interval_chart_data method | ||
def intervals_check(intervals, interval_mean) | ||
return { data: Array.new(intervals.length, interval_mean), label: 'Mean time spent' } if intervals.empty? | ||
end | ||
|
||
# provide data for volume metric chart using reviewer data | ||
def volume_metric_chart_data(labels, reviewer_data, all_reviewers_data) | ||
{ | ||
labels: labels, | ||
datasets: [{ label: 'vol.', backgroundColor: 'rgba(255,99,132,0.8)', borderWidth: 1, data: reviewer_data, yAxisID: 'bar-y-axis1' }, { label: 'avg. vol.', backgroundColor: 'rgba(255,206,86,0.8)', borderWidth: 1, data: all_reviewers_data, yAxisID: 'bar-y-axis2' }] | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# moves data of reviews in each round from a current round | ||
module ReviewMappingChartsHelper | ||
# Provide data for chart elements | ||
def initialize_chart_elements(reviewer) | ||
avg_vol_per_round(reviewer) | ||
labels.push 'Total' | ||
reviewer_data.push reviewer.overall_avg_vol | ||
all_reviewers_data.push @all_reviewers_overall_avg_vol | ||
[labels, reviewer_data, all_reviewers_data] | ||
end | ||
|
||
# display avg volume for all reviewers per round | ||
def avg_vol_per_round(reviewer) | ||
labels, round = 0, [] | ||
reviewer_data = [] | ||
all_reviewers_data = [] | ||
@num_rounds.times do |rnd| | ||
next unless @all_reviewers_avg_vol_per_round[rnd] > 0 | ||
round += 1 | ||
labels.push round | ||
reviewer_data.push reviewer.avg_vol_per_round[rnd] | ||
all_reviewers_data.push @all_reviewers_avg_vol_per_round[rnd] | ||
end | ||
end | ||
|
||
# The data of all the reviews is displayed in the form of a bar chart | ||
def display_volume_metric_chart(reviewer) | ||
labels, reviewer_data, all_reviewers_data = initialize_chart_elements(reviewer) | ||
data = volume_metric_chart_data(labels, reviewer_data, all_reviewers_data) | ||
options = provide_volume_metric_options | ||
horizontal_bar_chart data, options | ||
end | ||
|
||
# E2082 Generate chart for review tagging time intervals | ||
def display_tagging_interval_chart(intervals) | ||
# if someone did not do any tagging in 30 seconds, then ignore this interval | ||
threshold = 30 | ||
intervals = intervals.select { |v| v < threshold } | ||
unless intervals.empty? | ||
interval_mean = intervals.reduce(:+) / intervals.size.to_f | ||
end | ||
# build the parameters for the chart | ||
data = display_tagging_interval_chart_data(intervals, interval_mean) | ||
options = provide_tagging_options | ||
line_chart data, options | ||
end | ||
|
||
# Calculate mean, min, max, variance, and stand deviation for tagging intervals | ||
def calculate_key_chart_information(intervals) | ||
# if someone did not do any tagging in 30 seconds, then ignore this interval | ||
threshold = 30 | ||
interval_precision = 2 # Round to 2 Decimal Places | ||
intervals = intervals.select { |v| v < threshold } | ||
metric_information(intervals, interval_precision) | ||
# if no Hash object is returned, the UI handles it accordingly | ||
end | ||
|
||
# Get Metrics once tagging intervals are available | ||
def metric_information(intervals, interval_precision) | ||
# if intervals are empty return empty | ||
return {} if intervals.empty? | ||
|
||
metrics = {} | ||
# calculate various metric values | ||
metrics[:mean] = calculate_mean(intervals, interval_precision) | ||
metrics[:min] = intervals.min | ||
metrics[:max] = intervals.max | ||
metrics[:variance] = calculate_variance(intervals, metrics[:mean], interval_precision) | ||
metrics[:stand_dev] = calculate_standard_deviation(metrics[:variance], interval_precision) | ||
metrics | ||
end | ||
|
||
# calculate means from the intput intervals | ||
def calculate_mean(intervals, interval_precision) | ||
(intervals.reduce(:+) / intervals.size.to_f).round(interval_precision) | ||
end | ||
|
||
# calculate variance from intervals and mean | ||
def calculate_variance(intervals, mean, interval_precision) | ||
sum = intervals.inject(0) { |accum, i| accum + (i - mean)**2 } | ||
(sum / intervals.size.to_f).round(interval_precision) | ||
end | ||
|
||
# calculate standard deviation | ||
def calculate_standard_deviation(variance, interval_precision) | ||
Math.sqrt(variance).round(interval_precision) | ||
end | ||
end |
Oops, something went wrong.