Skip to content

Commit

Permalink
added battles to daily report
Browse files Browse the repository at this point in the history
  • Loading branch information
ppetermann committed Dec 13, 2013
1 parent d354ecb commit 15a2a9d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Kingboard/Model/Battle.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,9 @@ public static function generateBattle(BattleSettings $battleSetting)
);

}

public function toArray()
{
return $this->_data;
}
}
5 changes: 5 additions & 0 deletions src/Kingboard/Model/BattleSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public static function getActiveSettings($hours = 168)

return parent::doFind(__CLASS__, $qry);
}

public function toArray()
{
return $this->_data;
}
}
28 changes: 27 additions & 1 deletion src/Kingboard/Views/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use DateTime;
use Kingboard\Lib\Paginator;
use Kingboard\Model\BattleSettings;
use Kingboard\Model\Kill;
use Kingboard\Model\MapReduce\KillsByDay;
use Kingboard\Model\MapReduce\KillsByDayByEntity;
Expand Down Expand Up @@ -95,9 +96,34 @@ public function index(array $params)

$context['kills'] = $kills;
$context['action'] = "/day/" . $context['date'];
$this->render("date/daily.html", $context);

$dt = new DateTime($context['date']);

$criteria = array(
'$and' => array(
array("startdate" => array('$gt' => new MongoDate($dt->getTimestamp() -1))),
array("startdate" => array('$lt' => new MongoDate($dt->add(new \DateInterval("P1D"))->getTimestamp())))
)
);

if ($this->_context['ownerID']) {
$criteria['$or'] = array(
array("ownerCharacter" => $this->_context['ownerID']),
array("ownerCorporation" => $this->_context['ownerID']),
array("ownerAlliance" => $this->_context['ownerID']),
array("ownerFaction" => $this->_context['ownerID'])
);
}


$battles = BattleSettings::find($criteria);
// resolve collection to avoid count() of doom
$context["battles"] = array();
foreach ($battles as $battle) {
$context["battles"][] = $battle->toArray();
}

$this->render("date/daily.html", $context);

}
}
24 changes: 23 additions & 1 deletion templates/date/daily.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,29 @@ <h3 class="panel-title">Kill Page</h3>
<h3 class="panel-title">Battles</h3>
</div>
<div class="panel-body">
working on it
<div id="battlereports">
<div class="tab-pane">
<table class="table-bordered table-condensed table-striped col-md-12">
<thead>
<tr>
<th>System</th>
<th>Start</th>
<th>End</th>
<th>&nbsp;</th>
</tr>
</thead>
{% for report in battles%}
<tr>
<td>{{ report.system }}</td>
<td>{{ report.startdate.sec|date("Y-m-d H:i:s") }}</td>
<td>{{ report.enddate.sec|date("Y-m-d H:i:s") }}</td>
<td><a href="/battle/{{ report._id }}">details</a></td>
</tr>
{% endfor %}
</table>
</div>
</div>

</div>
</div>
</div>
Expand Down

0 comments on commit 15a2a9d

Please sign in to comment.