MCPcopy Create free account
hub / github.com/NextDotID/proof_server / proofChainChanges

Function proofChainChanges

controller/proof_chain_single.go:28–59  ·  view source on GitHub ↗

proofChainChanges returns proof chain one by one, unlinked.

(c *gin.Context)

Source from the content-addressed store, hash-verified

26
27// proofChainChanges returns proof chain one by one, unlinked.
28func 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}

Callers

nothing calls this directly

Calls 3

FindMethod · 0.80
ToProofChainItemMethod · 0.80
errorRespFunction · 0.70

Tested by

no test coverage detected