Merge pull request #326 from travis-ci/less-pusher-data

Don't save data from pusher that won't likely be used
This commit is contained in:
Piotr Sarnacki 2015-02-05 15:37:49 +01:00
commit 3780eaa13f
3 changed files with 25 additions and 0 deletions

View File

@ -4,4 +4,10 @@
Route = MainTabRoute.extend
reposTabName: 'recent'
activate: ->
@store.set('recentReposTabIsOpened', true)
deactivate: ->
@store.set('recentReposTabIsOpened', true)
`export default Route`

View File

@ -1,4 +1,5 @@
`import DS from 'ember-data'`
`import config from 'travis/config/environment'`
Store = DS.Store.extend
defaultAdapter: 'application'
@ -7,6 +8,22 @@ Store = DS.Store.extend
receivePusherEvent: (event, data) ->
[name, type] = event.split(':')
auth = @container.lookup('auth:main')
if !@get('recentReposTabIsOpened') && event != 'job:log' && auth.get('signedIn') &&
!config.pro && !config.enterprise
# if recent repos hasn't been opened yet, we can safely
# drop any events that doesn't belong to repos owned by
# the logged in user and that aren't related to any
# repositories that are already opened
permissions = auth.get('permissions')
if name == 'job'
id = data.job.repository_id
else if name == 'build'
id = data.repository.id
return if !@hasRecordForId('repo', id) && !permissions.contains(id)
if name == 'job' && data.job?.commit
@pushPayload(commits: [data.job.commit])

View File

@ -144,4 +144,6 @@ Auth = Ember.Object.extend
"#{location.protocol}//www.gravatar.com/avatar/#{@get('currentUser.gravatarId')}?s=48&d=mm"
).property('currentUser.gravatarId')
permissions: Ember.computed.alias('currentUser.permissions')
`export default Auth`