<commit_before>$(function() {
  // /sp_config/_design/config/pages/index.html
  var p = document.location.pathname.split('/'), 
    design = [p[1], p[2], p[3]];

    function activateMenu(section) {
      $("ul.nav li").removeClass("active");
      $("ul.nav li").has('[href=#'+section+']').addClass('active');
    }

    function checkIsAdmin(cb) {
      coux(["_session"], function(err, session) {
        if (err) {
          console.error(err)
        } else {
          if (session.userCtx.roles.indexOf("_admin") == -1) {
            // not an admin, need to login
            console.error("please login as an admin")
          } else {
            // an admin, let's rock
            cb(false, session);
          }
        }
      })
    }
    

    checkIsAdmin(function(err, userCtx) {
      coux(design, function(err, doc) {
        var config = doc.sp_config,
          usersByAppView = [config.users_db, '_design','syncpoint', '_view', 'by_app'],
          SyncpointRouter = Backbone.Router.extend({
            routes : {
              "" : "appsWithUserCount",
              "apps" : "appsWithUserCount",
              "users" : "allUsersWithApp",
              "users/by-app/:id" : "usersByApp",
              "sessions/verify/:id" : "verifySession",
              "channels" : "allChannels",
              "channels/by-app/:id" : "channelsByApp",
              "channels/by-user/:id" : "channelsByUser"
            },
            appsWithUserCount : function() {
              activateMenu("apps");
              var appsDiv = $("<div/>"), sessionsDiv = $("<div/>");
              appsDiv.autoview({
                query : usersByAppView.concat({limit : 100, group : true}),
                template : function(data) {
                  data.rows.forEach(function(row) {
                    row.users = row.value == 1 ? "user" : "users";
                  });
                  return Mustache.render($('#appsWithUserCount').html(), data);
                }
              })
              sessionsDiv.autoview({
                query : [ // todo this should be a view of the _users db
                  config.users_db, "_design","syncpoint", "_view", "byPairingTypeAndState", 
                  {key : ["session-admin","new"], include_docs : true}
                ], 
                template : Mustache.compile($('#newAdminSessions').html())
              });<commit_msg>update view query to show pending console pairing requests<commit_after>$(function() {
  // /sp_config/_design/config/pages/index.html
  var p = document.location.pathname.split('/'), 
    design = [p[1], p[2], p[3]];

    function activateMenu(section) {
      $("ul.nav li").removeClass("active");
      $("ul.nav li").has('[href=#'+section+']').addClass('active');
    }

    function checkIsAdmin(cb) {
      coux(["_session"], function(err, session) {
        if (err) {
          console.error(err)
        } else {
          if (session.userCtx.roles.indexOf("_admin") == -1) {
            // not an admin, need to login
            console.error("please login as an admin")
          } else {
            // an admin, let's rock
            cb(false, session);
          }
        }
      })
    }
    

    checkIsAdmin(function(err, userCtx) {
      coux(design, function(err, doc) {
        var config = doc.sp_config,
          usersByAppView = [config.users_db, '_design','syncpoint', '_view', 'by_app'],
          SyncpointRouter = Backbone.Router.extend({
            routes : {
              "" : "appsWithUserCount",
              "apps" : "appsWithUserCount",
              "users" : "allUsersWithApp",
              "users/by-app/:id" : "usersByApp",
              "sessions/verify/:id" : "verifySession",
              "channels" : "allChannels",
              "channels/by-app/:id" : "channelsByApp",
              "channels/by-user/:id" : "channelsByUser"
            },
            appsWithUserCount : function() {
              activateMenu("apps");
              var appsDiv = $("<div/>"), sessionsDiv = $("<div/>");
              appsDiv.autoview({
                query : usersByAppView.concat({limit : 100, group : true}),
                template : function(data) {
                  data.rows.forEach(function(row) {
                    row.users = row.value == 1 ? "user" : "users";
                  });
                  return Mustache.render($('#appsWithUserCount').html(), data);
                }
              })
              sessionsDiv.autoview({
                query : [ // todo this should be a view of the _users db
                  config.users_db, "_design","syncpoint", "_view", "byPairingTypeAndState", 
                  {key : ["console","new"], include_docs : true}
                ], 
                template : Mustache.compile($('#newAdminSessions').html())
              });
{'fraction_non_alphanumeric': 0.15488285299606055, 'fraction_numerical': 0.0033174372797014308, 'mean_word_length': 1.6949720670391062, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1526575', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1338, 'n_words': 254}