DKP Log Parser Forum Index
 Forum FAQ   Search   Register   Log in 
 About   Download   Forum   Wiki   Development
Upload raid as batch: batching dkp adjustment events

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DKP Log Parser Forum Index -> Suggestions - Completed

Author

Message

impishfae



Joined: 19 Jun 2006
Posts: 125
Location: Australia

PostPosted: Mon Jun 19, 2006 2:14 pm    Post subject: Upload raid as batch: batching dkp adjustment events

Reply with quote


Status: Included in version 1.4.0

Our guild is investigating the use of DKP for the first time and are happy to discover tools out there to make the fear-inducing administration easier in any way.

The admin crew have settled on time based dkp as the most equitable way of assigning dkp, and we've been using the 'upload raid as batch' to make our raid listings less prolific.

However the dkp adjustments per member can sometimes be quite a few, and this results in a bucket of mental arithmetic for a member to work out how much dkp they accumulated in a single raid.

Not being much of a php coder, I hacked together a patch in the plugin to compress the dkp adjustments into a single line with a total of the time based dkp the member earned for that raid and a summary of the minutes they were present in the raid for so they have an idea of why they've earned that amount of dkp.

Changed 'addRaidBatch' subroutine below from dkprpc.php for possible inclusion in a future version if people think it'd be useful. It should probably have a switch in the GUI, but my Java skills are massively out of date and I had a moment of panic at all the template classes. Smile

Code:
function addRaidBatch($params) {
   global $db, $xmlrpcerruser;
   if ($params->getNumParams() != 7) {
      return new xmlrpcresp(0, $xmlrpcerruser+3, "Incorrect number of parameters.");
   }

   $user = toScalar($params->getParam(0));
   $password = toScalar($params->getParam(1));
   $raidNames = toScalar($params->getParam(2));
   $timestamps = toScalar($params->getParam(3));
   $descriptions = toScalar($params->getParam(4));
   $dkpRewards = toScalar($params->getParam(5));
   $participants = toScalar($params->getParam(6));
      
   if(!hasUploadPermission($user, $password)) {
      return new xmlrpcresp(0, $xmlrpcerruser+1, "Permission denied.");
   }
   
   if(count($raidNames) == 0) {
      return new xmlrpcresp(0, $xmlrpcerruser+3, "No data to process.");
   }
   
   //Add summary raid.
   $raidId = createRaid($raidNames[0], "", $timestamps[0], "0.00", $user);
   $allParticipants = array();
   
    // These should probably be in an object rather than two hacky arrays.
    $partwithdkp = array();
    $partwithtimes = array();

   //Add up individual adjustments.
   foreach($raidNames as $key => $name) {
      $reward = $dkpRewards[$key];
      $time = $timestamps[$key];
      $note = $descriptions[$key];
      $groupKey = generateGroupKey($time, $note, $reward);
      foreach($participants[$key] as $participant) {
         if(!in_array($participant, $allParticipants)) {
            $allParticipants[] = $participant;

         }
            // Accumulate the dkp the participant has earned per interval.
            $partwithdkp[$participant] += $reward;
            // Accumulate the number of minutes this participant has been in the raid for. Calculate out the number of minutes per interval and sum.
            $pieces = explode(" ", $note);
            $from = explode(":", $pieces[2]);
            $to = explode(":", $pieces[4]);
            $partwithtimes[$participant] += (mktime($to[0],$to[1]) - mktime($from[0],$from[1]))/60;
        }
    }
   
    // Store just one adjustment per participant
    foreach($allParticipants as $participant)
    {
         //Add the adjustment.
         $query = $db->build_query('INSERT',
            array(
               'adjustment_value'      => $partwithdkp[$participant],
               'adjustment_date'      => $time,
               'member_name'         => $participant,
               'adjustment_reason'      => $name." (".$partwithtimes[$participant]." mins)",
               'adjustment_added_by'   => $user,
               'adjustment_group_key'   => $groupKey
            )
         );
         if(!$db->query('INSERT INTO '.ADJUSTMENTS_TABLE.$query)) {
            return new xmlrpcresp(0, $xmlrpcerruser+1, mysql_error());
         }
         
         //Update the earned value.
         $query = "UPDATE ".MEMBERS_TABLE." ".
            "SET member_adjustment = member_adjustment + ".$db->escape($reward)." ".
               "WHERE member_name='".$db->escape($participant)."'";
          if(!$db->query($query)) {
            return new xmlrpcresp(0, $xmlrpcerruser+1, mysql_error());
         }
      
   }
   
   //Add all particpants to the summary.
   foreach($allParticipants as $member) {
      //Ignore any non-members.
      $sql = "SELECT member_id FROM ".MEMBERS_TABLE."
            WHERE member_name = '".$db->escape($member)."'";
      $id = $db->query_first($sql);
      if($id === false) {
         return new xmlrpcresp(0, $xmlrpcerruser+1, mysql_error());
      }      
   
      if($id > 0) {
         if(!addAttendee($raidId, $member)) {
            return new xmlrpcresp(0, $xmlrpcerruser+3, mysql_error());
         }
      }
   }
   
   return new xmlrpcresp(new xmlrpcval($raidId, "int"));
}

Back to top

Lokorin
Site Admin


Joined: 03 Apr 2006
Posts: 697

PostPosted: Mon Jun 19, 2006 9:20 pm    Post subject:

Reply with quote


Nice! Many people request things like this.

I will have to think a bit on how to include it in 1.4.0, seeing as the times do not always represent the amount of time participated because of reward interval padding. Adding a new method to the server interface is possible, in which case the 1.4.0 client could supply the total time spent as a separate parameter. Another question is whether the actual amount of time participated in the raid should be shown, or just the amount of time that the player has been rewarded for (both values are available in 1.4.0).

I might be able to think a bit clearer after some sleep.

Back to top

impishfae



Joined: 19 Jun 2006
Posts: 125
Location: Australia

PostPosted: Mon Jun 19, 2006 10:20 pm    Post subject:

Reply with quote


Really, the having the minutes display on the 'reason' field was just a nicety, pre-empting our guildies spasming over why they received 5.43 dkp while someone else received 6.12.

Given weighting on intervals and whatnot, the minutes participated doesn't necessarily directly relate to the time-based dkp earned, but it at least provides a hand-waving approximation of the info.

To really show people where their dkp came from, you'd need to have all the gory detail of each interval and its weighting and dkp stored somewhere. The only way I can see of doing this (without having to modify eqdkp's database schema) would be to have a special 'RaidAdmin' member, which has the full set of intervals on it and earns maximum dkp for every raid, with a final adjustment after each raid that resets its dkp back to zero. So if people want to see the data that the calculation was using on a given raid, they could go check out the info on the 'RaidAdmin' member for that raid and see the detailed breakdown.

Nother suggestion for summary raid
In lieu of doing quite that much work as outlined above, I figure I might just change the name of the summary raid to also include the maximum number of minutes and possibly the maximum amount of dkp available on that raid, so people can compare their info to the summary info and forehead-slap themselves for not being there on time. Smile It isn't as good as the total breakdown by interval, but it's better than nothing.

'Nother suggestion which I'll get around to sending in a patch for soon
I want to change the event adding code so that the raid name is automatically prefixed to make it easier to see where that adjustment came from. At the moment I can't do this in the plugin (the addEvent call doesn't have the raidname available to it), so that's waiting til I unpack my Java brain from storage. (Ironic, since my professional career to date has been 100% Java, before I went all pointy-haired management and spent more time tweaking perl-based tools like Bugzilla)

Back to top

Lokorin
Site Admin


Joined: 03 Apr 2006
Posts: 697

PostPosted: Tue Jun 20, 2006 11:44 am    Post subject:

Reply with quote


Quote:
To really show people where their dkp came from, you'd need to have all the gory detail of each interval and its weighting and dkp stored somewhere.


Or export the raid to forum code or something similar. Or maybe an separate EQDKP plugin that displays every last bit of information about the raid in a separate window or something?

Back to top

impishfae



Joined: 19 Jun 2006
Posts: 125
Location: Australia

PostPosted: Tue Jun 20, 2006 12:59 pm    Post subject:

Reply with quote


Yeah! Exporting to forum would do the job just fine. (Though our forums happen to use html which is neither plain text, xml, wiki or BB markup. Just to make life difficult. Not that another exporter would be difficult to write. I'll post one up if I write one.)

Certainly a new eqdkp plugin would do the job, but that sounds too much like hard work. Wink

Back to top

Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    DKP Log Parser Forum Index -> Suggestions - Completed All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
SoftGreen 1.1 phpBB theme © DaTutorials.com 2005