Fix pusher to work with new ember-data
This commit just fixes things to the point where pusher updates are applied to the store properly. This still lacks a business logic fixes, so for example we won't update lastBuild's field, because there's no such information from pusher.
This commit is contained in:
parent
60348781d6
commit
81898e422f
|
@ -47,8 +47,10 @@ Store = DS.Store.extend
|
||||||
|
|
||||||
return unless @canHandleEvent(event, data)
|
return unless @canHandleEvent(event, data)
|
||||||
|
|
||||||
|
console.log(event, data)
|
||||||
|
|
||||||
if name == 'job' && data.job?.commit
|
if name == 'job' && data.job?.commit
|
||||||
@pushPayload(commits: [data.job.commit])
|
@push(this.normalize('commit', data.job.commit))
|
||||||
|
|
||||||
if name == 'build' && data.build?.commit
|
if name == 'build' && data.build?.commit
|
||||||
# TODO: commit should be a sideload record on build, not mixed with it
|
# TODO: commit should be a sideload record on build, not mixed with it
|
||||||
|
@ -67,7 +69,7 @@ Store = DS.Store.extend
|
||||||
}
|
}
|
||||||
delete(data.build.commit)
|
delete(data.build.commit)
|
||||||
|
|
||||||
@pushPayload(commits: [commit])
|
@push(this.normalize('commit', commit))
|
||||||
|
|
||||||
if event == 'job:log'
|
if event == 'job:log'
|
||||||
data = data.job
|
data = data.job
|
||||||
|
@ -81,13 +83,13 @@ Store = DS.Store.extend
|
||||||
_loadOne: (type, json) ->
|
_loadOne: (type, json) ->
|
||||||
payload = {}
|
payload = {}
|
||||||
payload[type.pluralize()] = [json[type]]
|
payload[type.pluralize()] = [json[type]]
|
||||||
@pushPayload(payload)
|
@push(this.normalize(type, json))
|
||||||
|
|
||||||
# we get other types of records only in a few situations and
|
# we get other types of records only in a few situations and
|
||||||
# it's not always needed to update data, so I'm specyfing which
|
# it's not always needed to update data, so I'm specyfing which
|
||||||
# things I want to update here:
|
# things I want to update here:
|
||||||
if type == 'build' && (json.repository || json.repo)
|
if type == 'build' && (json.repository || json.repo)
|
||||||
data = json.repository || json.repo
|
data = json.repository || json.repo
|
||||||
@pushPayload(repos: [data])
|
@push(this.normalize('repo', data))
|
||||||
|
|
||||||
`export default Store`
|
`export default Store`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user