Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
b5161d80
Commit
b5161d80
authored
Dec 22, 2009
by
Richard Mansfield
Browse files
Graph historical user/group/view counts on admin home page
Signed-off-by:
Richard Mansfield
<
richardm@catalyst.net.nz
>
parent
4d0f782b
Changes
3
Show whitespace changes
Inline
Side-by-side
htdocs/admin/index.php
View file @
b5161d80
...
...
@@ -78,7 +78,7 @@ if (empty($upgrades)) {
$sitedata
=
site_statistics
();
if
(
!
empty
(
$sitedata
[
'weekly'
]))
{
$jsfiles
=
array
(
'js/PlotKit/excanvas.js'
,
'js/PlotKit/PlotKit.js'
);
$sitedata
[
'dataarray'
]
=
json_encode
(
$sitedata
[
'weekly'
]);
$sitedata
[
'dataarray'
]
=
json_encode
(
array
(
$sitedata
[
'weekly'
]
[
'view-count'
],
$sitedata
[
'weekly'
][
'user-count'
],
$sitedata
[
'weekly'
][
'group-count'
])
);
}
}
...
...
htdocs/lib/mahara.php
View file @
b5161d80
...
...
@@ -2209,21 +2209,24 @@ function cron_send_registration_data() {
* Cronjob to save weekly site data locally
*/
function
cron_site_data_weekly
()
{
require_once
(
get_config
(
'libroot'
)
.
'registration.php'
);
$current
=
site_data_current
();
$time
=
db_format_timestamp
(
time
());
insert_record
(
'site_data'
,
(
object
)
array
(
'ctime'
=>
$time
,
'type'
=>
'user-count'
,
'value'
=>
count_records_select
(
'usr'
,
'id > 0 AND deleted = 0'
)
,
'value'
=>
$current
[
'users'
]
,
));
insert_record
(
'site_data'
,
(
object
)
array
(
'ctime'
=>
$time
,
'type'
=>
'group-count'
,
'value'
=>
count_records
(
'group'
,
'deleted'
,
0
)
,
'value'
=>
$current
[
'groups'
]
,
));
insert_record
(
'site_data'
,
(
object
)
array
(
'ctime'
=>
$time
,
'type'
=>
'view-count'
,
'value'
=>
count_records_select
(
'view'
,
'owner <> 0'
)
,
'value'
=>
$current
[
'views'
]
,
));
}
...
...
htdocs/lib/registration.php
View file @
b5161d80
...
...
@@ -179,7 +179,7 @@ function registration_data() {
return
$data_to_send
;
}
function
site_
statistics
()
{
function
site_
data_current
()
{
return
array
(
'name'
=>
get_config
(
'sitename'
),
'users'
=>
count_records_select
(
'usr'
,
'id > 0 AND deleted = 0'
),
...
...
@@ -188,4 +188,25 @@ function site_statistics() {
);
}
function
site_statistics
()
{
$data
=
site_data_current
();
$lastyear
=
db_format_timestamp
(
time
()
-
60
*
60
*
12
*
365
);
$values
=
array
(
$lastyear
,
'view-count'
,
'user-count'
,
'group-count'
);
$weekly
=
get_records_sql_array
(
'
SELECT ctime, type, value, '
.
db_format_tsfield
(
'ctime'
,
'ts'
)
.
'
FROM {site_data}
WHERE ctime >= ? AND type IN (?,?,?)
ORDER BY ctime, type'
,
$values
);
if
(
$weekly
&&
count
(
$weekly
)
>
count
(
$values
)
-
1
)
{
$data
[
'weekly'
]
=
array
(
'user-count'
=>
array
(),
'group-count'
=>
array
(),
'view-count'
=>
array
());
$keys
=
array
(
'user-count'
=>
0
,
'group-count'
=>
0
,
'view-count'
=>
0
);
foreach
(
$weekly
as
&
$r
)
{
$data
[
'weekly'
][
$r
->
type
][
$keys
[
$r
->
type
]
++
]
=
array
(
$keys
[
$r
->
type
],
$r
->
value
);
}
}
return
(
$data
);
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment