Skip to main content
6 of 8
I know i am churning, but the joint is a ghost town right now. no harm - no foul
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60

Simple Activity Monitor - For Educational Purposes only.

This Soapi.JS script, if abused is likely to provoke frowns from those whom you would like to see smiles.

Note: the dataset is only valid if the entire user base is pulled, and on just about any other site there are far too many users for the execution to be even remotely considered non-abusive or even remotely useful.

So - bottom line is: you could have figured it out yourself, so no harm in me posting it.

Let's just say it is an example of how to get cached/throttled paged results from the api with JavaScript.


OOPS Busted abusing the API!!!

 Dont try this on stack overflow or really any other site with more than a couple thousand users. Really
Page 26 of 26
52 seconds Jeff Atwood
74 seconds Bill the Lizard
3 minutes rchern
3 minutes Don
3 minutes Nippysaurus
5 minutes Steffen Opel
7 minutes Ivo Trompert
12 minutes code poet
13 minutes Roger Pate
14 minutes Adam Smith
17 minutes ahsteele
18 minutes Mark Hurd
....

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="http://soapi.info/code/js/stable/3rd-party/jquery-1.4.1.js" type="text/javascript"></script>

    <script src="http://soapi.info/code/js/stable/scripts/Soapi.js" type="text/javascript"></script>

    <script type="text/javascript">

        // Soapi JavaScript Library
        // http://stackapps.com/questions/494
        // http://soapi.info/

        $(function() {

            var apiKey = '';

            Soapi.RouteFactory("api.stackapps.com", apiKey).Users()
            .getPagedResponse(function(data) {

                var table = $("#status").append("<table>");

                for (var i in data.items.sort(function(a, b) {
                    return b.last_access_date - a.last_access_date
                })) {
                    var timeAgo = Soapi.Utilities.getTimeAgo(data.items[i].last_access_date);
                    var who = data.items[i].display_name;
                    table.append("<tr><td>" + timeAgo + "</td><td>" + who + "</td></tr>");
                }
            }, null, function(data) {
                $("#status")
                .html("Page " + data.page + " of " + (Math.floor(data.total / data.pagesize) + 1));
            });
        });
    </script>

</head>
<body>
    <p>
        Dont try this on stack overflow or really any other site with more than a couple
        thousand users. Really</p>
    <div id="status">
    </div>
</body>
</html>
Sky Sanders
  • 12.1k
  • 3
  • 32
  • 60