Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (69 sloc) 3.31 KB
<?xml version="1.0" encoding="UTF-8" ?>
<table xmlns="" securityLevel="user">
<sampleQuery> select * from {table}</sampleQuery>
<select itemPath="" produces="XML">
<key id='friendguid' type='xs:string' paramType='variable' />
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:://';
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:://';
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
//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");
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");
//return the three sets of results
default xml namespace = '';
response.object = <root>{root}</root>;
Jump to Line
Something went wrong with that request. Please try again.