-
Notifications
You must be signed in to change notification settings - Fork 5
/
update_editors_summary.php
executable file
·38 lines (31 loc) · 1.1 KB
/
update_editors_summary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/php
<?php ;
// Copyright: see COPYING
// Authors: see git-blame(1)
chdir ('public_html');
include "lib/setup.php";
evidence_create_tables();
$q = theDb()->query ("INSERT IGNORE INTO editor_summary (oid) SELECT oid FROM eb_users");
if (theDb()->isError($q)) die ($q->getMessage());
$q = theDb()->query ("SELECT DISTINCT oid FROM eb_users");
if (theDb()->isError($q)) die ($q->getMessage());
while ($editor =& $q->fetchRow()) {
$votes = theDb()->getOne
("SELECT COUNT(*) FROM web_vote_latest
WHERE vote_oid=?",
array($editor["oid"]));
$u = theDb()->query
("REPLACE INTO editor_summary (oid, total_edits, latest_edit, webvotes)
SELECT edit_oid,
COUNT(*) new_total_edits,
MAX(edit_timestamp) new_latest_edit,
?
FROM edits
WHERE edit_oid=? AND is_draft=0
GROUP BY edit_oid",
array($votes, $editor["oid"]));
if (theDb()->isError($u)) die ($u->getMessage());
$r = theDb()->getRow ("SELECT * FROM editor_summary LEFT JOIN eb_users ON eb_users.oid=editor_summary.oid WHERE editor_summary.oid=?",
array($editor["oid"]));
if (theDb()->isError($r)) die ($r->getMessage());
}