Skip to content

Commit

Permalink
Merge branch 'release/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2edchimp committed Oct 2, 2015
2 parents 123f633 + 132970a commit f7e0b4f
Show file tree
Hide file tree
Showing 21 changed files with 607 additions and 108 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# Release 0.5.1

- 25cd71d Versionbump.
- ee81179 Updated BR index to new prepopulated statistics.
- d0654b5 Db tables updated for EVE SDE Vanguard.
- f08d36e Merge branch 'feature/damage-numbers' into develop
- 8627700 Updated database schemas.
- e67ed73 Fixed case.
- b13ec7f Update Combatatnts already added to a BattleParty, update all the stats when saving the Battle (down to the Combatant props).
- d2324f9 Fill `Combatant` damageComposition property with fetched values.
- 7a755e4 Add damageComposition property.
- 0c25aa9 Take damage values into account on battle creation.
- 620f152 Bugfix when checking successful instantiation of Combatant.
- 5b03485 Changed property name to fit imported one.
- e6c3744 Ignore deleted AND hidden combatants when calculating the statistics.
- 619fa9d Moved battle dependent stats update method into `Battle` class.
- 83ae13e Use prepopulated statistic fields.
- 0d77839 Make use of new prepopulated statistic fields.
- ca5aa9e Populate stat values up until battleparties.
- 43ccc42 Refetch kill mails to get damage numbers and store them as received or dealt.
- 5a719ef Rearranged code order to order to match corresponding parts on admin page.
- 54642a1 Bugfix, to actually use any other than the `default` theme.
- a470012 Linked ToC.
- 65e2efa Concretized theming instructions.
- 772e2fd Added "Contribution" section.
- 2b1a271 Bugfix.
- d91deaf Updated contents, esp. installation, update and customization instructions.
- 017dfdc Completed legal stuff.
- 7e6f6c2 Fixed typo.
- 6adc937 Merge branch 'release/0.5.0' into develop

# Release 0.5.0

- 42a7cec Versionbump.
Expand Down
173 changes: 172 additions & 1 deletion classes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function refetchKillMailsForMissingLossValues() {
return null;

if ($refetchCount > 0) {
$result["message"] = "$refetchCount kills completed by adding the missing loss values.";
$result["message"] = "$refetchCount kills completed by adding the missing loss values. You should redo all the corresponding calculations!";
} else {
$result = array(
"success" => false,
Expand All @@ -78,5 +78,176 @@ public static function refetchKillMailsForMissingLossValues() {
return $result;

}

public static function refetchKillMailsForMissingDamageValues() {

if (!User::isAdmin()) {
return array(
"success" => false,
"message" => "Administrator privileges are required to perform this action!"
);
}

$db = Db::getInstance();

$result = array(
"success" => true
);
$missingCount = -1;
$refetchCount = 0;

$combatants = $db->query(
"select c.*, ifnull(cc.corporationName, 'Unknown') as corporationName, ifnull(a.allianceName, '') as allianceName " .
"from invGroups as g right outer join invTypes as t " .
"on g.groupID = t.groupID " .
"right outer join brCombatants as c " .
"on t.typeID = c.shipTypeID " .
"left outer join brCorporations as cc " .
"on c.corporationID = cc.corporationID " .
"left outer join brAlliances as a " .
"on c.allianceID = a.allianceID " .
"where c.died = 1 and c.damageTaken <= 0.0"
);
if ($combatants === NULL || $combatants === FALSE) {
return array(
"success" => false,
"message" => "An error occurred when trying to collect the kills missing their damage values from database."
);
} else {
$missingCount = count($combatants);
}

foreach ($combatants as $combatant) {

$combatant = new Combatant($combatant);
// Maybe track the count of omitted combatants?
if ($combatant === null)
continue;

$killArray = KBFetch::fetchKill($combatant->killID);
foreach ($killArray as $kill) {

if ($kill->killID != $combatant->killID ||
!isset($kill->zkb) || !isset($kill->zkb->totalValue))
continue;

// Set the received damage in db ...
$combatant->damageTaken = intval($kill->victim->damageTaken);
$combatant->save();

// ... and dispatch the dealt damage values
foreach ($kill->attackers as $attacker) {
// Get the attacker's brCombatantID
$attackerID = $db->single(
'select brCombatantID ' .
'from brCombatants ' .
'where characterID = :characterID ' .
'and shipTypeID = :shipTypeID ' .
'and brBattlePartyID in (' .
'select brBattlePartyID from brBattleParties where battleReportID = (' .
'select battleReportID from brBattleParties where brBattlePartyID = :victimBattlePartyID limit 1' .
')' .
')',
array(
'characterID' => $attacker->characterID,
'shipTypeID' => $attacker->shipTypeID,
'victimBattlePartyID' => $combatant->brBattlePartyID
)
);
// We screwed up here :/
if ($attackerID === FALSE)
continue;

// Delete entries in table brDamageComposition of this attacker and victim
$db->query(
'delete from brDamageComposition ' .
'where brReceivingCombatantID = :victimID and brDealingCombatantID = :attackerID',
array(
'victimID' => $combatant->brCombatantID,
'attackerID' => $attackerID,
)
);

// And insert it as a new entry
$db->query(
'insert into brDamageComposition ' .
'(brReceivingCombatantID, brDealingCombatantID, brDamageDealt) ' .
'values ' .
'(:victimID, :attackerID, :dealtDamage)',
array(
'victimID' => $combatant->brCombatantID,
'attackerID' => $attackerID,
'dealtDamage' => $attacker->damageDone
)
);
}

$refetchCount++;

}

}

if ($missingCount <= 0)
return null;

if ($refetchCount > 0) {
$result["message"] = "$refetchCount kills completed by adding the missing damage values. You should redo all the corresponding calculations!";
} else {
$result = array(
"success" => false,
"message" => "No kill mail refetched in order to add missing damage values."
);
}

return $result;

}

public static function repopulateStatistics() {

$result = array(
"error" => "Something went totally wrong. Sorry, but there's no further information available."
);

$resultPartialFailures = false;
$resultStatisticsRepopulated = false;

$db = \Db::getInstance();

// Fetch all battles from database
$battles = $db->query(
'select * from brBattles'
);

if ($battles === FALSE) {
return array(
"error" => "Could not find any battles."
);
}

// Loop through each battle ...
foreach ($battles as $battle) {
$partialResult = \Battle::updateStats($battle["battleReportID"]);
if ($partialResult === true) {
$resultStatisticsRepopulated = true;
} else {
$resultPartialFailures = true;
}
}

if ($resultStatisticsRepopulated === true) {
$result = array(
"success" => "Statistic fields have been repopulated."
);
}

if ($resultPartialFailures === true) {
$results["error"] = "Some statistics could not be repopulated.";
}

return $result;

}

}
Loading

0 comments on commit f7e0b4f

Please sign in to comment.