Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cba554849d
Fetching contributors…

Cannot retrieve contributors at this time

file 71 lines (69 sloc) 3.389 kb
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd" securityLevel="user">
  <meta>
    <sampleQuery> select * from {table}</sampleQuery>
  </meta>
  <bindings>
    <select itemPath="root.install.app" produces="XML">
      <urls>
        <url></url>
      </urls>
      <inputs>
        <key id='friendguid' type='xs:string' paramType='variable' />
      </inputs>
      <execute><![CDATA[
function createInstallElement(update,type) {
var bits = update.itemurl.toString().split("/");
var appid = bits[bits.length-2].substring(1);//get the appid from the install url
var title = update.title.toString();
default xml namespace = '';
var el = <app who={type} id={appid}>{title}</app>;
default xml namespace = 'http:://social.yahooapis.com/v1/updates/schema.rng';
return el;
}

default xml namespace = '';
var root = <install/>;

//get my friends installs from updates
var friendapp_installs = null;
if (friendguid) {
//only do deltas to this friend
friendapp_installs = y.query('select title, itemtxt, itemurl from social.updates(1000) where guid=@guid and type="appInstall" | unique(field="itemtxt")',{guid:friendguid});
} else {
//all friends
friendapp_installs = y.query('select title, itemtxt, itemurl from social.updates(1000) where guid in (select guid from social.connections(0) where owner_guid=me) and type="appInstall" | unique(field="itemtxt")');
}
//get my installs from updates
var myapp_installs = y.query('select title, itemtxt, itemurl from social.updates(1000) where guid=me and type="appInstall" | unique(field="itemtxt")');
//we're going to keep a collection for each variant of the diff between my installs and my friend(s)
var myapp_installs = myapp_installs.results;
var friendapp_installs = friendapp_installs.results;
default xml namespace = 'http:://social.yahooapis.com/v1/updates/schema.rng';
for each (var myupdate in myapp_installs.update) {
y.log("myupdate "+myupdate.localName());
//use e4x to search for matching node in friendapp with the same itemtxt (appid)
var matching = friendapp_installs.update.(itemtxt==myupdate.itemtxt.toString());
if (matching.length()>0) {
//found, we both have it
root.install+=createInstallElement(myupdate,"shared");
//y.log("Found "+myupdate.title+" in both");
myupdate.@matched = true;
matching.@matched = true;
} else {
//not in my friends apps, so add it to me only list
//y.log("Found "+myupdate.title+" in mine only");
root.install+=createInstallElement(myupdate,"me");
myupdate.@matched = true;
}
}
//anything left in the friends app list that doesnt have a "match" attribute is not installed by me
for each (var friendupdate in friendapp_installs.update.(@matched!=true)) {
//y.log("Found "+friendupdate.title+" in my friends only");
root.install+=createInstallElement(friendupdate,"friend");
}
//return the three sets of results
default xml namespace = '';
response.object = <root>{root}</root>;
]]></execute>
    </select>
  </bindings>
</table>
Something went wrong with that request. Please try again.