Skip to content

Instantly share code, notes, and snippets.

@rondale-sc
Created August 2, 2016 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondale-sc/dd58b2975ae6808e33834201f0182dfe to your computer and use it in GitHub Desktop.
Save rondale-sc/dd58b2975ae6808e33834201f0182dfe to your computer and use it in GitHub Desktop.
import Ember from 'ember';
const { get } = Ember;
export default function() {
this.namespace = 'api/v1';
this.get('/emails', function({emails}, request) {
const folderName = request.queryParams.folderName;
const results = {};
results['inbox'] = emails.where(i => !get(i, 'trashedDate'));
results['trash'] = emails.where(i => get(i, 'trashedDate'));
results['starred'] = emails.where(i => get(i, 'starred'));
const json = this.serialize(results[folderName], 'email');
json.meta = {
inboxCount: results['inbox'].models.length,
trashCount: results['trash'].models.length,
starredCount: results['starred'].models.length
};
return json;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment