liquid_feedback_frontend

view lib/token/sync.lua @ 1851:a01d5c0604de

Removed debug output
author bsw
date Tue Mar 22 10:25:35 2022 +0100 (2022-03-22)
parents accb808d5b4a
children e593570a23c5
line source
1 function _G.sync_token()
2 local request = [[
3 {
4 "query": "query balanceNotificationMany($tokenSymbol: String) {
5 balanceNotificationMany(filter: { token_symbol: $tokenSymbol }) {
6 _id
7 account_pk
8 name
9 token_symbol
10 amount
11 contractAddress
12 owner
13 }
14 }",
15 "variables": {
16 "tokenSymbol": "]] .. config.token.token_name .. [["
17 }
18 }
19 ]]
21 local output, err, status = extos.pfilter(request, "curl", "--insecure", "-X", "POST", "-H", "Content-Type: application/json", "-H", "X-REQUEST-TYPE: GraphQL", "-d", "@-", config.token.graphql_url)
23 local data = json.import(output)
25 local privileges = Privilege:new_selector()
26 :add_where{ "unit_id = ?", config.token.unit_id }
27 :exec()
29 for i, privilege in ipairs(privileges) do
30 privilege:destroy()
31 end
33 for i, entry in ipairs(data.data.balanceNotificationMany) do
34 local member = Member:new_selector()
35 :join("member_profile", nil, "member_profile.member_id = member.id")
36 :add_where{ "member_profile.profile->>'" .. config.token.key_profile_field .."' = ?", entry.account_pk }
37 :optional_object_mode()
38 :exec()
39 if member then
40 local privilege = Privilege:new()
41 privilege.unit_id = config.token.unit_id
42 privilege.member_id = member.id
43 privilege.initiative_right = true
44 privilege.voting_right = true
45 privilege.weight = entry.amount
46 privilege:save()
47 end
48 end
50 end

Impressum / About Us