generated from edenia/full-stack-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #435 from edenia/dev
Production Release
- Loading branch information
Showing
88 changed files
with
898 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
const { hasuraUtil } = require('../utils') | ||
|
||
const save = async payload => { | ||
const mutation = ` | ||
mutation ($payload: global_amount_insert_input!) { | ||
insert_global_amount_one(object: $payload) { | ||
id | ||
eos_income | ||
usd_income | ||
usd_expense | ||
eos_expense | ||
election | ||
account | ||
} | ||
} | ||
` | ||
const data = await hasuraUtil.instance.request(mutation, { payload }) | ||
|
||
return data.insert_global_amount_one | ||
} | ||
|
||
const get = async (where, getMany = false) => { | ||
const query = ` | ||
query ($where: global_amount_bool_exp) { | ||
global_amount(where: $where) { | ||
id | ||
eos_income | ||
usd_income | ||
usd_expense | ||
eos_expense | ||
election | ||
account | ||
} | ||
} | ||
` | ||
const { global_amount } = await hasuraUtil.instance.request(query, { | ||
where | ||
}) | ||
|
||
return getMany ? global_amount : global_amount[0] | ||
} | ||
|
||
const update = async ({ where, _set }) => { | ||
const mutation = ` | ||
mutation update($where: global_amount_bool_exp!, $_set: global_amount_set_input) { | ||
update_global_amount(where: $where, _set: $_set) { | ||
returning { | ||
id | ||
} | ||
} | ||
} | ||
` | ||
const data = await hasuraUtil.instance.request(mutation, { | ||
where, | ||
_set | ||
}) | ||
|
||
return data.update_eden_transaction | ||
} | ||
|
||
const getAggregate = async where => { | ||
const query = ` | ||
query ($where: global_amount_bool_exp) { | ||
global_amount_aggregate(where: $where) { | ||
aggregate { | ||
sum { | ||
eos_income | ||
usd_income | ||
} | ||
} | ||
} | ||
} | ||
` | ||
const { global_amount } = await hasuraUtil.instance.request(query, { | ||
where | ||
}) | ||
|
||
return global_amount?.aggregate?.sum || {} | ||
} | ||
|
||
module.exports = { | ||
save, | ||
get, | ||
update, | ||
getAggregate | ||
} |
81 changes: 81 additions & 0 deletions
81
hapi/src/gql/eden_total_expense_by_delegate_and_election.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
const { hasuraUtil } = require('../utils') | ||
|
||
const save = async payload => { | ||
const mutation = ` | ||
mutation ($payload: total_expense_by_delegate_and_election_insert_input!) { | ||
insert_total_expense_by_delegate_and_election_one(object: $payload) { | ||
id | ||
} | ||
} | ||
` | ||
const data = await hasuraUtil.instance.request(mutation, { payload }) | ||
|
||
return data.insert_total_expense_by_delegate_and_election_one | ||
} | ||
|
||
const get = async (where, getMany = false) => { | ||
const query = ` | ||
query ($where: total_expense_by_delegate_and_election_bool_exp) { | ||
total_expense_by_delegate_and_election(where: $where) { | ||
id | ||
eos_amount | ||
usd_amount | ||
id_election | ||
category | ||
} | ||
} | ||
` | ||
const { total_expense_by_delegate_and_election } = | ||
await hasuraUtil.instance.request(query, { | ||
where | ||
}) | ||
|
||
return getMany | ||
? total_expense_by_delegate_and_election | ||
: total_expense_by_delegate_and_election[0] | ||
} | ||
|
||
const update = async ({ where, _set }) => { | ||
const mutation = ` | ||
mutation update($where: total_expense_by_delegate_and_election_bool_exp!, $_set: total_expense_by_delegate_and_election_set_input) { | ||
update_total_expense_by_delegate_and_election(where: $where, _set: $_set) { | ||
returning { | ||
id | ||
} | ||
} | ||
} | ||
` | ||
const data = await hasuraUtil.instance.request(mutation, { | ||
where, | ||
_set | ||
}) | ||
|
||
return data.update_eden_transaction | ||
} | ||
|
||
const getAggregate = async where => { | ||
const query = ` | ||
query ($where: total_expense_by_delegate_and_election_bool_exp) { | ||
total_expense_by_delegate_and_election_aggregate(where: $where) { | ||
aggregate { | ||
sum { | ||
eos_amount | ||
} | ||
} | ||
} | ||
} | ||
` | ||
const { total_expense_by_delegate_and_election } = | ||
await hasuraUtil.instance.request(query, { | ||
where | ||
}) | ||
|
||
return total_expense_by_delegate_and_election?.aggregate?.sum?.eos_amount || 0 | ||
} | ||
|
||
module.exports = { | ||
save, | ||
get, | ||
update, | ||
getAggregate | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.