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

API to get user stats #17

Closed
2 tasks done
Tracked by #40
gjermundgaraba opened this issue Aug 17, 2022 · 0 comments
Closed
2 tasks done
Tracked by #40

API to get user stats #17

gjermundgaraba opened this issue Aug 17, 2022 · 0 comments
Assignees

Comments

@gjermundgaraba
Copy link
Contributor

gjermundgaraba commented Aug 17, 2022

Create a new service to get user stats (i.e. new folder on the root of this project called "stats")

  • Create the new service with the new API
  • Write the tests

Return:

  • Number of available (unused) vouchers
  • Number of used vouchers
  • Array of types of materials the user has deposited (aggregated)

Example:

{
  "numberOfAvailableVouchers": 3,
  "numberOfUsedVouchers": 42,
  "depositAmounts": [
    {
      "materialDefinition": {
        "plasticType": "PET"
      },
      "magnitude": 0, // 0 = Weight, 1 = Count. See commons/models.go
      "amount": 1.2
    },
    {
      "materialDefinition": {
        "plasticType": "HDPE"
      },
      "magnitude": 0, // 0 = Weight, 1 = Count. See commons/models.go
      "amount": 13.37
    },
    {
      "materialDefinition": {
        "plasticType": "Snus"
      },
      "magnitude": 1, // 0 = Weight, 1 = Count. See commons/models.go
      "amount": 314
    }
  ]
}

To see more details on the definition of the deposit amount model, look at https://github.com/empowerchain/deposit-backend/blob/main/commons/models.go

When you are done the file structure of the repo would probably look something like this:

- admin/ [+]
- commons/ [+]
- deposit/ [+]
- organization/ [+]
- scheme/ [+]
- stats/ [-]
  - stats.go
  - stats_test.go
- tmp/ [+]
...
@gjermundgaraba gjermundgaraba changed the title API to get number of kg's delivered by user API to get user stats Sep 6, 2022
@gfant gfant closed this as completed Sep 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants