Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/async census creation #70

Merged
merged 18 commits into from
Sep 8, 2023
Merged

Conversation

lucasmenendez
Copy link
Collaborator

now when the user tries to create a new census, it is included into the database and generated in background, a new census column has been created on the database called 'published' that indicates if the current census is built and published on IP

…f POST /census expected request (by default to false), new census_type column created on the database to store the census type
…he database and generated in background, a new census column has ben created on the database called 'published' that indicates if the current census is built and published on IPFS
@lucasmenendez lucasmenendez added the enhancement New feature or request label Aug 29, 2023
@lucasmenendez lucasmenendez added this to the v0.2.0 milestone Aug 29, 2023
@lucasmenendez lucasmenendez self-assigned this Aug 29, 2023
@lucasmenendez lucasmenendez linked an issue Aug 30, 2023 that may be closed by this pull request
@lucasmenendez
Copy link
Collaborator Author

New flow to create and publish a census:

  1. Create a token
wget --method POST \
  --header 'Accept: */*' \
  --header 'Content-Type: application/json' \
  --body-data '{"id": "0xa117000000f279D81A1D3cc75430fAA017FA5A2e","type": "erc20"}' \
  --output-document \
  - https://census3.dev.vocdoni.net/api/token

Response:

Ok
  1. Create census with strategyID that includes the created token:
wget --method POST \
  --header 'Accept: */*' \
  --header 'Content-Type: application/json' \
  --body-data '{"strategyId": 1}' \
  --output-document \
  - https://census3.dev.vocdoni.net/api/census

Response:

{
  "queueId": "7c208c69d85dc187725395124514baea3bc5498c"
}
  1. Get the census creation status from the queue with the queueID resulting of previous request:
wget --method GET \
  --header 'Accept: */*' \
  --output-document \
  - https://census3.dev.vocdoni.net/api/census/queue/7c208c69d85dc187725395124514baea3bc5498c

Response:

{
  "census": {
    "censusId": 1,
    "strategyId": 1,
    "merkleRoot": "8f2d3b5c15445e6ec3bfe6a5f52c2be1de916ca296ce7474982b4a66b34d3f30",
    "uri": "ipfs://bafybeihb5krnn2muubms27gn6egevrjxeb5z7ttp35eqzi3b33ejqwntka",
    "size": 10,
    "weight": "320822718213393032631430073323170650669553037360",
    "chainId": 5,
    "anonymous": true
  },
  "done": true,
  "error": null
}

…the creation of a census that is already created, it is returned through the queue
@lucasmenendez lucasmenendez marked this pull request as ready for review September 1, 2023 15:43
api/censuses.go Outdated Show resolved Hide resolved
api/censuses.go Show resolved Hide resolved
api/censuses.go Outdated Show resolved Hide resolved
api/censuses.go Outdated Show resolved Hide resolved
api/censuses.go Outdated Show resolved Hide resolved
api/censuses.go Outdated Show resolved Hide resolved
api/censuses.go Outdated Show resolved Hide resolved
api/censuses.go Show resolved Hide resolved
api/censuses.go Outdated Show resolved Hide resolved
api/types.go Outdated Show resolved Hide resolved
@lucasmenendez lucasmenendez merged commit 9073525 into main Sep 8, 2023
6 checks passed
@lucasmenendez lucasmenendez deleted the feature/async_census_creation branch September 8, 2023 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create and publish census ASYNC
2 participants