diff --git a/graphql/index.js b/graphql/index.js index c0498f9744a8dc33c8f2c2b78dd4c305efba6ab5..630319e8c1e06be02643c7371407d2dc2f0c12f2 100644 --- a/graphql/index.js +++ b/graphql/index.js @@ -16,7 +16,19 @@ export default ctx => { }) const link = from([ssrMiddleware, httpLink]) - const cache = new InMemoryCache({addTypename:false}) + const cache = new InMemoryCache({ + typePolicies: { + Event: { + keyFields: ['block',['bct']] + }, + EventId: { + keyFields: ['member',['hash'],'inOut'] + }, + Identity: { + keyFields: ['hash'] + } + } + }) return { link, diff --git a/pages/index.vue b/pages/index.vue index a328af1410de8ab6ef8d9841efb2a9c75636d60e..5b568a835fa426d5ce13f33d117b3e8a7cbfbe1b 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -45,7 +45,7 @@ export default { query: gql`query LastEvents($start: Int64, $end: Int64) { membersCount(start: $start, end: $end) { idList { - id { + member : id { pubkey uid status @@ -56,23 +56,29 @@ export default { } } inOut + }, + block { + bct } } } `, variables(){return {start:today-86400*2,end:today}}, update (data) { + console.log(data) let result = {'entrees':[],'sorties':[]} for (let i = 0; i < data.membersCount.length; i++) { - let member = data.membersCount[i].idList[0] - member.id.inOut = member.inOut + for (let j =0; j < data.membersCount[i].idList.length; j++) { + let member = data.membersCount[i].idList[j] + member.member.inOut = member.inOut - if (member.inOut || member.id.status=='MEMBER') { - if (result['entrees'].filter(function(e) { return e.hash === member.id.hash; }).length == 0) { - result['entrees'].push(member.id) + if (member.inOut || member.member.status=='MEMBER') { + if (result['entrees'].filter(function(e) { return e.hash === member.member.hash; }).length == 0) { + result['entrees'].push(member.member) + } + } else { + result['sorties'].push(member.member) } - } else { - result['sorties'].push(member.id) } }