You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
946B

  1. package main
  2. import (
  3. "biukop.com/sfm/loan"
  4. "net/http"
  5. )
  6. type chartTypeOfLoans struct {
  7. Kind string `json:"kind"`
  8. Share float64 `json:"share"`
  9. Amount float64 `json:"amount"`
  10. }
  11. func apiV1ChartTypeOfLoans(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  12. peopleId := r.URL.Path[len(apiV1Prefix+"chart/type-of-loans/"):]
  13. data := loan.TypeOfLoan(peopleId)
  14. //send out
  15. apiV1SendJson(data, w, r, ss)
  16. }
  17. func apiV1ChartAmountOfLoans(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  18. peopleId := r.URL.Path[len(apiV1Prefix+"chart/amount-of-loans/"):]
  19. data := loan.TypeOfLoan(peopleId)
  20. //send out
  21. apiV1SendJson(data, w, r, ss)
  22. }
  23. func getDummyData() []chartTypeOfLoans {
  24. return []chartTypeOfLoans{
  25. {Kind: "Solar2", Share: 0.052},
  26. {Kind: "Wind1", Share: 0.225},
  27. {Kind: "Other1", Share: 0.192},
  28. {Kind: "Hydroelectric1", Share: 0.175},
  29. {Kind: "Nuclear1", Share: 0.238},
  30. {Kind: "Coal1", Share: 0.118},
  31. }
  32. }