/////////////////
// Tweet Store //
/////////////////
tr.data = function(){
  
  // hash of hashes for storing query stores
  var _h = new Hash();
  
  return {
    
    /**
    * get a query store
    **/
    get : function(query){
      return _h;
    },
    
    /**
    * store response json
    **/
    store : function(json){
      if (!json) return;
      json.each(function(tweet){
        if (!_h.get(tweet.id)) {
          _h.set(tweet.id, tr.tweet.extend(tweet));
          tweet.convert();
        }
      }.bind(this));
    },
    
    /**
    * return the ids for a given query
    **/
    ids : function(query){
      return this.get().keys();
    },
    
    /**
    * return the tweets for a query ordered by date
    **/
    unplayedTweets : function(){
      return this.get().values().select(
        function(tweet){
          return !tweet.played;
      })
      .sortBy(
        function(tweet){
          return tweet.lastModified;
      });
    }
    
  };
}();
