Skip to content

Instantly share code, notes, and snippets.

@gippy
Last active January 2, 2018 13:25
Show Gist options
  • Save gippy/e5b49d2370ae4dfaa7588d7b270f911e to your computer and use it in GitHub Desktop.
Save gippy/e5b49d2370ae4dfaa7588d7b270f911e to your computer and use it in GitHub Desktop.
class Reporting {
# DI of database connection
constructor(db) {}
getStore(store) {
find document with id of store
return the document
}
afterPush(store) {
update document with id of store
increase itemsCount by 1 ($inc)
return updated document
}
beforePersist(store, newlyPersistedItemsCount) {
update document with id of store
increase persistedItemsCount by newlyPersistedItemsCount ($inc)
return updated document
}
afterPersist(store, key, fields, newlyUploadedBytes) {
update document with id of store
add key to set of keys ($addToSet)
add fields to set of field ($addToSet)
increase s3PutCount by 1 ($inc)
increase uploadedBytes by newlyUploadedBytes ($inc)
return updated document
}
afterDownload(store, newly downloadedBytes) {
update document with id of store
increase s3GetCount by 1 ($inc)
increase downloadedBytes by newlyDownloadedBytes ($inc)
return updated document
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment