Esempio n. 1
0
</p>
<?php 
echo elgg_view('plugins/admin/stats/plugin_select');
// default parameters for downloads plot
$num_days = 30;
$guid = (int) get_input('guid', 0);
if ($guid != 0) {
    $num_days = 0;
}
if ($guid) {
    $project = get_entity($guid);
    echo "<h4>Stats for {$project->title}</h4>";
} else {
    echo "<h4>Stats for all plugins</h4>";
}
$histogram = plugins_get_downloads_histogram($guid, $num_days);
// create string for flot
$plot_string = '';
foreach ($histogram as $k => $v) {
    $plot_string .= "[{$k}, {$v}],";
}
$plot_string = rtrim($plot_string, ',');
?>
<div id="plugins_download_plot"></div>

<script type="text/javascript" src="<?php 
echo $vars['url'];
?>
mod/community_plugins/vendors/flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript">
$(function () {
Esempio n. 2
0
<?php

/**
 * Finds daily download total outliers and replaces them with the median
 */
$guid = get_input('guid');
if (!$guid) {
    register_error("No GUID specified");
    forward(REFERER);
}
$preview = get_input('preview', FALSE);
$downloads = plugins_get_downloads_histogram($guid, 0);
$mean = array_sum($downloads) / count($downloads);
$std_dev = 0;
foreach ($downloads as $count) {
    $std_dev += ($count - $mean) * ($count - $mean);
}
$std_dev /= count($downloads);
$std_dev = sqrt($std_dev);
// calculate cutoff - 95% assuming Gaussian distribution
$cutoff = $mean + 2 * $std_dev;
// calculate median
sort($downloads);
$median = $downloads[(int) round(0.5 * count($downloads))];
// delete annotations beyond the daily cutoff - there must be a better way to do this
// This does not process the last day
$downloads = get_annotations($guid, 'object', 'plugin_project', 'download', '', 0, 9999999, 0, 'asc', 0);
$start_date = $downloads[0]->time_created;
$current_day = 0;
$count = 0;
$annotations_removed = 0;