/* note that this gets set at the toplevel!
* so we can call it from onsubmit... */
signin_submit = function(name, pw) {
mjt.run('action_result', signin, [name, pw]);
return false;
};
signout_onclick = function() {
mjt.run('action_result', signout);
return false;
};
mjt.mqlread({
"type":"/type/usergroup",
"id":"/freebase/bots",
"member":[{
"id":null
}]
})
var bots = {};
for (var bot in qbots.result.member) {
bots[qbots.result.member[bot].id] = 1;
}
${getStaff(dateA, dateB, bots)}
error
Error text: $msg.message .
You may need to
sign in
mjt.mqlread({
"type":"/type/usergroup",
"id":"/freebase/mwstaff",
"member":[{
"id":null
}]
})
var mwstaff = {};
for (var staff in qmwstaff.result.member) {
mwstaff[qmwstaff.result.member[staff].id] = 1;
}
${getActivity(dateA, dateB, bots, mwstaff)}
error
Error text: $msg.message ,
You may need to
sign in
${mjt.log('Get Activity', startDate, endDate, bots, staff, dateObj, cursor, activity)}
if (!(dateObj)) {
cursor=true;
ittr = 0;
dateObj = new Date(0);
dateObj.setUTCFullYear(startDate.getUTCFullYear(), startDate.getUTCMonth(), startDate.getUTCDate());
dateObj = new Date(dateObj.valueOf() + 48 *3600 * 1000);
// Day plus two because it takes that long for tally to show up.
// The code queries tallies within the past 24 hours to view writes within the 24 hours before that.
}
ittr++;
var aMonth = dateObj.getUTCMonth(); aMonth++ ; if (aMonth < 10) { aMonth = "0" + aMonth + "";}
var aDate = dateObj.getUTCDate(); if (aDate < 10) { aDate = "0" + aDate + "";}
var dateStrA = dateObj.getUTCFullYear() + "-" + aMonth + "-" + aDate;
var dayBeforeObj = new Date (dateObj.valueOf() - (24*3600*1000));
var bMonth = dayBeforeObj.getUTCMonth(); bMonth++ ; if (bMonth < 10) { bMonth = "0" + bMonth + "";}
var bDate = dayBeforeObj.getUTCDate(); if (bDate < 10) { bDate = "0" + bDate + "";}
var dateStrB = dayBeforeObj.getUTCFullYear() + "-" + bMonth + "-" + bDate;
// Changes are tallied on dayBefore, the actally happened the day prior to that.
var dayOfWriteObj = new Date (dateObj.valueOf() - (2*24*3600*1000));
var cMonth = dayOfWriteObj.getUTCMonth(); cMonth++ ; if (cMonth < 10) { cMonth = "0" + cMonth + "";}
var cDate = dayOfWriteObj.getUTCDate(); if (cDate < 10) { cDate = "0" + cDate + "";}
var dateStrC = dayOfWriteObj.getUTCFullYear() + "-" + cMonth + "-" + cDate;
if (!(activity)) {
var activity={};
}
if (!(activity[dateStrC])) {
activity[dateStrC] = {"total":0};
}
mjt.mqlread([{
"a:primitives_written":{
"link":{
"valid" : null,
"timestamp":null,
"timestamp<":dateStrA,
"timestamp>":dateStrB
},
"limit":1,
"sort":"-link.timestamp",
"value":null
},
"b:primitives_written":{
"limit":1,
"link":{
"valid" : null,
"timestamp":null,
"timestamp<":dateStrB
},
"optional":true,
"limit":1,
"sort":"-link.timestamp",
"value":null
},
"type":"/freebase/user_activity",
"user":null
}], { cursor: cursor})
for (var user in qact.result) {
var username = qact["result"][user]["user"];
var prior =0;
var total = qact["result"][user]["a:primitives_written"]["value"];
if (qact["result"][user]["b:primitives_written"]) {
var prior = qact["result"][user]["b:primitives_written"]["value"];
}
var diff = total - prior;
activity[dateStrC][username] = diff;
// if (((mjt.urlquery.staff==1) || (!(staff[username]))) && ((mjt.urlquery.robots==1) || (!(bots[username]))) && (username != '/user/root')) {
// activity[dateStrC]["total"] = activity[dateStrC]["total"] + diff;
// }
}
${getActivity(startDate, endDate, bots, staff, dateObj, qact.next_cursor, activity, ittr)}
var newDate = new Date(dateObj.valueOf() + 24*3600*1000);
Possible loop detected in ${dateStrC} moving on.
${showRes(bots, staff, activity)}
${getActivity(startDate, endDate, bots, staff, newDate, true, activity,0)}
Error!
${mjt.log('Error in', qact)}
Error text: $msg.message
You may need to
sign in
You are signed in as $mjt.metaweb_user.name.
sign out
var ymd = timestamp.split("-");
var months = ['NaN', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
/*datetime[1] = datetime[1].slice(0,8)*/
${months[ymd[1] *1]} ${ymd[2]}, ${ymd[0]}
var rowindex=0;
var dates = [];
var names = [];
var eachtotals = {};
for (var dateString in activity)
{
dates.push(dateString);
for (var username in activity[dateString])
{
if (!(eachtotals[username] == null))
{
eachtotals[username] = eachtotals[username] + activity[dateString][username];
} else {
eachtotals[username] = activity[dateString][username];
names.push(username);
}
if (((mjt.urlquery.staff==1) || (!(staff[username]))) && ((mjt.urlquery.robots==1) || (!(bots[username]))) && (username != '/user/root')) {
if (!(eachtotals[username] == 'total')) {
activity[dateString]['total'] += activity[dateString][username];
//mjt.log('asdf' , dateString, username, activity[dateString][username] , activity[dateString]['total']);
}
}
}
eachtotals['total'] += activity[dateString]['total'];
}
function sortByTotal(a,b)
{
return (eachtotals[b] - eachtotals[a]);
}
names.sort(sortByTotal);
| User |
${formatTime(date)} | Total |
|
rowindex++;
|
${name} |
|
${eachtotals[name]} |
var timeObj = new Date();
timeObj.setTime(timeObj.valueOf() - (30*3600*1000));
var eY = timeObj.getUTCFullYear(); if (mjt.urlquery.eY) {eY = mjt.urlquery.eY;}
var eM = timeObj.getUTCMonth()+1; if (mjt.urlquery.eM) {eM = mjt.urlquery.eM;}
var eD = timeObj.getUTCDate(); if (mjt.urlquery.eD) {eD = mjt.urlquery.eD;}
timeObj.setTime(timeObj.valueOf() - (4 * 24*3600*1000));
var sY = timeObj.getUTCFullYear(); if (mjt.urlquery.sY) {sY = mjt.urlquery.sY;}
var sM = timeObj.getUTCMonth() +1; if (mjt.urlquery.sM) {sM = mjt.urlquery.sM;}
var sD = timeObj.getUTCDate(); if (mjt.urlquery.sD) {sD = mjt.urlquery.sD;}
dateObjA = new Date(0);
dateObjA.setUTCFullYear(sY, sM -1, sD); //Month minus one because Jan is 0, Dec is 11
dateObjB = new Date(0);
dateObjB.setUTCFullYear(eY, eM -1, eD); //Jan is 0
New Primitives Written
${getBots(dateObjA, dateObjB)}