proofChainChanges returns proof chain one by one, unlinked.
(c *gin.Context)
| 26 | |
| 27 | // proofChainChanges returns proof chain one by one, unlinked. |
| 28 | func proofChainChanges(c *gin.Context) { |
| 29 | req := ProofChainSingleRequest{} |
| 30 | if err := c.BindQuery(&req); err != nil { |
| 31 | errorResp(c, http.StatusBadRequest, errors.New("Param error")) |
| 32 | return |
| 33 | } |
| 34 | if req.Count <= 0 { |
| 35 | req.Count = 10 |
| 36 | } |
| 37 | if req.Count >= 100 { |
| 38 | req.Count = 100 |
| 39 | } |
| 40 | |
| 41 | pc_found := make([]model.ProofChain, 0, 0) |
| 42 | tx := model.ReadOnlyDB.Where("id > ?", req.LastID).Limit(req.Count).Order("id ASC").Find(&pc_found) |
| 43 | if tx.Error != nil { |
| 44 | errorResp(c, http.StatusInternalServerError, tx.Error) |
| 45 | return |
| 46 | } |
| 47 | |
| 48 | proof_chains := lo.Map(pc_found, func(pc model.ProofChain, i int) ProofChainSingleItem { |
| 49 | return ProofChainSingleItem{ |
| 50 | ProofChainItem: pc.ToProofChainItem(), |
| 51 | Avatar: pc.Persona, |
| 52 | ID: pc.ID, |
| 53 | } |
| 54 | }) |
| 55 | |
| 56 | c.JSON(http.StatusOK, ProofChainSingleResponse{ |
| 57 | Links: proof_chains, |
| 58 | }) |
| 59 | } |
nothing calls this directly
no test coverage detected