kendraio / kendra_hub

Kendra Hub
https://www.kendra.io/kendra-hub
GNU General Public License v2.0
4 stars 1 forks source link

Check algorithm for calculating splits #46

Open dahacouk opened 9 years ago

dahacouk commented 9 years ago

The split calculation seems to go wrong when sampling tracks that include more than one part in the track timeline. Somehow parts not included in the sample range are included in the sample because they are part of the track. Where the track is a collection of parts. Also there's nothing to stop parts overlapping within one track. Perhaps the easiest thing to do right now is not allow multiple parts per track. Perhaps we'll solve that issue later?

To do

BBGuy commented 9 years ago

For other issues see https://docs.google.com/document/d/1HQ-C7TfVBDiM8AL1TzA7wg-uEiYSsBTeYrEfLLeOl7k/edit

BBGuy commented 9 years ago

We identified that this issue is on the sample page and it looks like once sampled the calculations are correct. We need to make sure the calculations are used on the sample view

dahacouk commented 9 years ago

We could make it look something like this...

kendra_hub_sample_algorithm_-_google_docs

Where first chart is for Rights, then next 3 for specific splits within each right and then aggregated.

BBGuy commented 9 years ago

The issue with the sample screen is as follows: 1) The view filter is used to workout what tracks are to be shown according to the exposed filter (slider) 2) The calculations of the included tracks use used start/end properties of their entity (same code as the entity page). To resolve this issue we need to be able to override the start end of the track with the values of the sliders, without breaking it for the asset page. I can easily get the values of the sliders in the view using PHP:

$view = views_get_current_view();
$debug = print_r($view->exposed_input, TRUE);
drupal_set_message($debug);

return:

Array ( [range] => Array ( [value] => 54 [value2] => 82 ) ) 

will review the code to find how this can be accomplished

BBGuy commented 9 years ago

To do

BBGuy commented 9 years ago

Code to use inside the view fields

Global: PHP (Points) field code

Value code:

if (module_exists('kendra_wf') && function_exists('kendra_wf_calc_points_value') ) {
  if (isset($view->exposed_input['range'])) {
    // If we have a filter provide the start and end points
    $start_p = $view->exposed_input['range']['value'];
    $end_p = $view->exposed_input['range']['value2'];
    return kendra_wf_calc_points_value($data->nid,  $static, $start_p, $end_p);
  }
  else {
    // If no filter applied use 0-100.
    return kendra_wf_calc_points_value($data->nid,  $static, 0, 100);    
  }
}
else {
  return '';
}

Output code:

<?php
  print $value;
?>

Global: PHP (Points) field code

Value code:

if (module_exists('kendra_wf') && function_exists('kendra_wf_calc_points_value') ) {
  if (isset($view->exposed_input['range'])) {
    // If we have a filter provide the start and end points
    $start_p = $view->exposed_input['range']['value'];
    $end_p = $view->exposed_input['range']['value2'];
    return kendra_wf_calc_points_value($data->nid,  $static, $start_p, $end_p);
  }
  else {
    // If no filter applied use 0-100.
    return kendra_wf_calc_points_value($data->nid,  $static, 0, 100);    
  }
}

Output code:

<?php
if (module_exists('kendra_wf') && function_exists('kendra_wf_calc_points_split') ) {
  print kendra_wf_calc_points_split($data->nid, $value, $static) . '%';
}
else {
 print '';
}
?>
BBGuy commented 9 years ago

Live testing results

I have pushed all changes live. I used the left right test that worked as expected see attached. However Sampling of the right side of Stairway to Heaven did not produce the same result as my local test did and doesn't look correct (see both local dev and live images below)

Left right test

live-left-right-test

Stairway to Heaven Local

local-swth-test

Stairway to Heaven Live

live-swth-test

BBGuy commented 9 years ago

Looks like the issue is that if a legal entities has more then one contribution, then contributions can override each other so out of the two vocal tracks by Robert Plant only one is picked up. Will investigate the code.

BBGuy commented 9 years ago

I have fixed the issue on the Asset page, but still need to fix it on the sample page

BBGuy commented 9 years ago

Sample page was a small config issue. So all looking good see image live-swth-fixed

BBGuy commented 9 years ago

Daniel can you please review and close if you are happy

BBGuy commented 9 years ago

The above image to check calculations go with 90-100 that works out a clean 20%,20%,20%,40%