oh yeah, its gettin forward bitches!

This commit is contained in:
Nael 2014-03-06 01:38:20 +01:00
parent 98b57e0af4
commit 39f4e347eb
10 changed files with 94 additions and 25 deletions

View File

@ -33,4 +33,7 @@ class api_uvote extends \SYSTEM\API\api_login {
return votes::vote_submit($poll_ID);
}
public static function call_graph_bt_to_uvote_overall_by_time($timespan = 84600){
return votes::get_graph_bt_to_uvote_overall_by_time($timespan);}
}

View File

@ -1,6 +1,18 @@
<?php
class votes {
public static function get_graph_bt_to_uvote_overall_by_time ($timespan = 84600,$returnasjson = true){
$result = array();
$res = \DBD\UVOTE_DATA_GRAPH_BT_TO_UVOTE_OVERALL_BY_TIME::QQ(array($timespan));
while ($row = $res->next()){
$result[] = array( 0 => $row['day'],
'class_match' => $row['class_match'] / ($row['class_match']+$row['class_mismatch']+1),
'class_mismatch' => $row['class_mismatch'] / ($row['class_match']+$row['class_mismatch']+1));
}
return $returnasjson ? SYSTEM\LOG\JsonResult::toString($result) : $result;
}
public static function getAllVotesOfGroup($groupid){
return \DBD\UVOTE_GENERATE_VOTELIST::QA(array($groupid));}

View File

@ -0,0 +1,19 @@
<?php
namespace DBD;
class UVOTE_DATA_GRAPH_BT_TO_UVOTE_OVERALL_BY_TIME extends \SYSTEM\DB\QP {
protected static function query(){
return new \SYSTEM\DB\QQuery(get_class(),
//pg
'',
//mys
'SELECT
DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP(a.`timestamp`) - MOD(UNIX_TIMESTAMP(a.`timestamp`),?)),"%Y/%m/%d %H:%i:%s") as day,
SUM(CASE WHEN a.choice = c.bt_choice THEN 1 ELSE 0 END) class_match,
SUM(CASE WHEN a.choice = c.bt_choice THEN 0 ELSE 1 END) class_mismatch
FROM uvote_data as a
LEFT JOIN (Select choice, poll_ID FROM uvote_data GROUP BY choice LIMIT 1) b ON a.poll_ID = b.poll_ID
LEFT JOIN uvote_votes as c ON a.poll_ID = c.ID
WHERE bt_choice
GROUP BY day;'
);}}

View File

@ -7,5 +7,5 @@ class UVOTE_DATA_PARTY_PER_POLL extends \SYSTEM\DB\QP {
//pg
'',
//mys
'SELECT * FROM `uvote_votes_per_party` WHERE `poll_ID` = ?;'
'SELECT * FROM `uvote_votes_per_party` WHERE `poll_ID` = ? ORDER BY party;'
);}}

View File

@ -7,5 +7,5 @@ class UVOTE_DATA_USERS_CHOICE_PER_POLL extends \SYSTEM\DB\QP {
//pg
'',
//mys
'SELECT COUNT(*) as count, choice FROM uvote_data WHERE `poll_ID` = ? GROUP BY choice ORDER BY count DESC;'
'SELECT COUNT(*) as count, choice FROM uvote_data WHERE `poll_ID` = ? GROUP BY choice ORDER BY count DESC, choice;'
);}}

View File

@ -9,8 +9,10 @@ class default_page extends SYSTEM\PAGE\Page {
'<script type="text/javascript" language="JavaScript" src="'.SYSTEM\WEBPATH(new PCRYPTOSHA(),'jquery.md5.js').'"></script>'.
'<script type="text/javascript" language="JavaScript" src="'.SYSTEM\WEBPATH(new PCRYPTOSHA(),'jquery.sha1.js').'"></script>'.
'<script type="text/javascript" language="JavaScript" src="'.SYSTEM\WEBPATH(new PLIB(),'jquery.countdown\jquery.countdown.js').'"></script>'.
'<script src="'.SYSTEM\WEBPATH(new PPAGE(),'default_page/js/loadtexts.js').'"></script>';
'<script src="'.SYSTEM\WEBPATH(new PPAGE(),'default_page/js/account_create.js').'"></script>';
'<script src="'.SYSTEM\WEBPATH(new PPAGE(),'default_page/js/loadtexts.js').'"></script>'.
'<script src="'.SYSTEM\WEBPATH(new PPAGE(),'default_page/js/account_create.js').'"></script>'.
'<script src="https://www.google.com/jsapi" type="text/javascript"></script>'.
'<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]});</script>';
}
private function css(){

View File

@ -79,12 +79,16 @@ $(document).ready(function() {
$(this).tab('show');
load_user_main_tab($(this).attr('action'));
});
//load_user_main_tab('user_main_uVote');
});
});
});
function drawChart(){
//load_visualisation('#graph_bt_uv_overall',84600);
}
function load_user_main_tab(action){
switch(action){
@ -236,4 +240,33 @@ function loadApiPic(id) {
}).complete(function() {
});
}
function load_visualisation(id, timespan){
$('img#loader').show();
$.getJSON('./api.php?call=graph_bt_to_uvote_overall_by_time',function(json){
if(!json || json.status != true || !json.result){
$('img#loader').hide();
return;
}
json = json.result;
$('img#loader').hide();
var data = new google.visualization.DataTable();
first = true;
$.each(json[0], function(key, value){
if(first){
data.addColumn('datetime',key);
first = false;
} else {
data.addColumn('number',key);
}
});
$.each(json, function(key, value){
first = true;
data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));});
console.log(data);
var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "300", height: "250"};
new google.visualization.LineChart(document.getElementById(id)).draw(data, options);
});
}

View File

@ -1,25 +1,21 @@
<table style="margin-bottom: 5px; width: 95%; height: 100px; border: solid lightgray 1px; background: beige;">
<tr>
<!--<td class="${vote_class}" style="width: 10px; margin-top: 10px; border-left: 1px solid lightgray;">
</td>-->
<td style="padding: 5px; padding-top: 0;">
<h5>${title}</h5>
<img src="${frontend_logos}icon_urn_${vote_class}.png"/>
<a class="btn btn-primary btn-small btn_vote" style="" poll_ID="${ID}">${full_vote_btn}</a>
</td>
<td class="${bt_vote_class}" style="width: 80px; margin-top: 10px; border-left: 1px solid lightgray;">
<td class="${bt_vote_class}" style="width: 80px; margin-top: 5px; border-left: 1px solid lightgray; padding: 2px;">
<img src="${frontend_logos}icon_bt.png" width="80"/>
${bt}
</td>
<td class="${uv_vote_class}" style="width: 60px; height: 100%; border-left: 1px solid lightgray;">
<td class="${uv_vote_class}" style="width: 60px; height: 100%; border-left: 1px solid lightgray; padding: 2px;">
<img src="${frontend_logos}icon_urn.png" width="20"/>
<span style="float: right"><font size="2">uVote</font></span>
<br/>
${uv}
<span class="badge badge-info" style="">${uv_count}</span>
<br>
<br>
<br>
<span class="badge" style="">${uv_count}</span>
</td>
<td style="margin: 0; padding: 0; width: 3px;" >
<table class="poll_time" time="${time_end}" style="width: 100%; height: 100%; margin: 0; padding: 0;">

View File

@ -1,4 +1,4 @@
<div style="width: 90%;">
<div style="width: 50%; padding: 60px;">
<img src="${frontend_logos}logo2.png"/>
<br />
<br />

View File

@ -1,13 +1,17 @@
<div style="float: left">
<table style="border-collapse: separate;
border-spacing: 10px 5px; width: 350px;">
${welcome_text}
<tr>
<h5>Übereinstimmung von uVote & Politik</h5>
${uvote_to_bt}
</tr>
</table>
</div>
<div style="width: 100%;">
${welcome_text}
<div style="float: left;">
<table style="border-collapse: separate; border-spacing: 10px 5px; width: 350px;">
<tr>
<h5>Übereinstimmung von uVote & Politik</h5>
${uvote_to_bt}
</tr>
</table>
</div>
<div id="graph_bt_uv_overall" style="float: left; width: 300px;"></div>
<script type="text/javascript" language="JavaScript">load_visualisation('graph_bt_uv_overall',84600);</script>
</div>
<div style="clear: both"></div>
<div style="width: 50%; margin-bottom: 30px; float: left;">
<h5>Entscheidungsverhalten der uVote Community</h5>
<span style="">