Created
August 2, 2016 19:01
-
-
Save rondale-sc/dd58b2975ae6808e33834201f0182dfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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