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

[cms] Add ProposalSpendingSummary and ProposalSpendingDetails #1224

Merged
merged 14 commits into from
Jul 24, 2020

Conversation

alexlyp
Copy link
Member

@alexlyp alexlyp commented Jun 18, 2020

This PR adds 2 new requests that will allow administrators to review
spending of approved proposal tokens.

ProposalSpendingSummary takes no arguments and just uses the
politeiawww API to get approved proposals at proposals and
test-proposals.decred.org.


Note: This call requires admin privileges.

**Route:** `GET /v1/admin/spendingsummary`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's documented as /admin/spendingsummary here but the route is /proposals/spendingsummary


Note: This call requires admin privileges.

**Route:** `POST /v1/admin/spendingdetails`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's documented as /admin/spendingdetails but the route is /proposals/spendingdetails

Copy link
Member

@tiagoalvesdulce tiagoalvesdulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On /spendingsummary, the title field is returning empty (""). See:

{
   "proposals":[
      {
         "token":"088ee532a5f20d2ff13d8ce23c811560b48c6d6aa0ab83bc88a0556fde93bc03",
         "title":"",
         "totalbilled":80000,
         "invoices":[
            {
               "status":0,
               "timestamp":0,
               "userid":"8172cb38-32b6-4d0f-9607-6f9f1677746c",
               "username":"admin",
               "publickey":"991468ac6644f44297ce2a74c153077381f8487d2e4dfda1deb8b23834d05974",
               "signature":"",
               "file":null,
               "version":"",
               "input":{
                  "version":0,
                  "month":5,
                  "year":2020,
                  "exchangerate":1411,
                  "contractorname":"",
                  "contractorlocation":"",
                  "contractorcontact":"",
                  "contractorrate":2000,
                  "paymentaddress":"",
                  "lineitems":[
                     {
                        "type":1,
                        "domain":"Development",
                        "subdomain":"oimigs",
                        "description":"opa",
                        "proposaltoken":"088ee532a5f20d2ff13d8ce23c811560b48c6d6aa0ab83bc88a0556fde93bc03",
                        "subuserid":"",
                        "subrate":0,
                        "labor":2400,
                        "expenses":0
                     }
                  ]
               },
               "payment":{
                  "token":"",
                  "address":"",
                  "txids":[
                     ""
                  ],
                  "timestarted":0,
                  "timelastupdated":0,
                  "amountneeded":0,
                  "amountreceived":0,
                  "status":0
               },
               "censorshiprecord":{
                  "token":"3f85d32c6ce9bdd61ebe1f4ca47d82b90ff6c07ee37e2115d2347fe79a06f62d",
                  "merkle":"",
                  "signature":""
               }
            }
         ]
      }
   ]
}

This is the proposal: https://test-proposals.decred.org/proposals/088ee532a5f20d2ff13d8ce23c811560b48c6d6aa0ab83bc88a0556fde93bc03

Copy link
Member

@tiagoalvesdulce tiagoalvesdulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/spendingdetails is returning empty state. See the return of this endpoint when the token is6bf75611b6a4d53d8bcedb1adc00f9e40e146cc4b442e4ee00d29db399c92929:

{
   "details":{
      "token":"",
      "title":"",
      "totalbilled":0,
      "invoices":null
   }
}

The return of /spendingsummary shows that this proprosal actually has billings associated with it. See:

{
   "proposals":[
      {
         "token":"6bf75611b6a4d53d8bcedb1adc00f9e40e146cc4b442e4ee00d29db399c92929",
         "title":"",
         "totalbilled":80000,
         "invoices":[
            {
               "status":0,
               "timestamp":0,
               "userid":"8172cb38-32b6-4d0f-9607-6f9f1677746c",
               "username":"admin",
               "publickey":"991468ac6644f44297ce2a74c153077381f8487d2e4dfda1deb8b23834d05974",
               "signature":"",
               "file":null,
               "version":"",
               "input":{
                  "version":0,
                  "month":5,
                  "year":2020,
                  "exchangerate":1411,
                  "contractorname":"",
                  "contractorlocation":"",
                  "contractorcontact":"",
                  "contractorrate":4000,
                  "paymentaddress":"",
                  "lineitems":[
                     {
                        "type":1,
                        "domain":"Development",
                        "subdomain":"opaaaa",
                        "description":"bao?",
                        "proposaltoken":"6bf75611b6a4d53d8bcedb1adc00f9e40e146cc4b442e4ee00d29db399c92929",
                        "subuserid":"",
                        "subrate":0,
                        "labor":1200,
                        "expenses":0
                     }
                  ]
               },
               "payment":{
                  "token":"",
                  "address":"",
                  "txids":[
                     ""
                  ],
                  "timestarted":0,
                  "timelastupdated":0,
                  "amountneeded":0,
                  "amountreceived":0,
                  "status":0
               },
               "censorshiprecord":{
                  "token":"81bb8a603fea68db115b3860129a770b404282d31a455491ce24c7c6fdfa7726",
                  "merkle":"",
                  "signature":""
               }
            }
         ]
      },
      {
         "token":"088ee532a5f20d2ff13d8ce23c811560b48c6d6aa0ab83bc88a0556fde93bc03",
         "title":"",
         "totalbilled":101000,
         "invoices":[
            {
               "status":0,
               "timestamp":0,
               "userid":"8172cb38-32b6-4d0f-9607-6f9f1677746c",
               "username":"admin",
               "publickey":"991468ac6644f44297ce2a74c153077381f8487d2e4dfda1deb8b23834d05974",
               "signature":"",
               "file":null,
               "version":"",
               "input":{
                  "version":0,
                  "month":5,
                  "year":2020,
                  "exchangerate":1411,
                  "contractorname":"",
                  "contractorlocation":"",
                  "contractorcontact":"",
                  "contractorrate":1000,
                  "paymentaddress":"",
                  "lineitems":[
                     {
                        "type":1,
                        "domain":"Development",
                        "subdomain":"iiii",
                        "description":"oooooooooo",
                        "proposaltoken":"088ee532a5f20d2ff13d8ce23c811560b48c6d6aa0ab83bc88a0556fde93bc03",
                        "subuserid":"",
                        "subrate":0,
                        "labor":1260,
                        "expenses":0
                     }
                  ]
               },
               "payment":{
                  "token":"",
                  "address":"",
                  "txids":[
                     ""
                  ],
                  "timestarted":0,
                  "timelastupdated":0,
                  "amountneeded":0,
                  "amountreceived":0,
                  "status":0
               },
               "censorshiprecord":{
                  "token":"00a9916752270f180fc0391263c29af812e509c406bc3bbfe7b1540d799dcbca",
                  "merkle":"",
                  "signature":""
               }
            },
            {
               "status":0,
               "timestamp":0,
               "userid":"8172cb38-32b6-4d0f-9607-6f9f1677746c",
               "username":"admin",
               "publickey":"991468ac6644f44297ce2a74c153077381f8487d2e4dfda1deb8b23834d05974",
               "signature":"",
               "file":null,
               "version":"",
               "input":{
                  "version":0,
                  "month":5,
                  "year":2020,
                  "exchangerate":1411,
                  "contractorname":"",
                  "contractorlocation":"",
                  "contractorcontact":"",
                  "contractorrate":2000,
                  "paymentaddress":"",
                  "lineitems":[
                     {
                        "type":1,
                        "domain":"Development",
                        "subdomain":"oimigs",
                        "description":"opa",
                        "proposaltoken":"088ee532a5f20d2ff13d8ce23c811560b48c6d6aa0ab83bc88a0556fde93bc03",
                        "subuserid":"",
                        "subrate":0,
                        "labor":2400,
                        "expenses":0
                     }
                  ]
               },
               "payment":{
                  "token":"",
                  "address":"",
                  "txids":[
                     ""
                  ],
                  "timestarted":0,
                  "timelastupdated":0,
                  "amountneeded":0,
                  "amountreceived":0,
                  "status":0
               },
               "censorshiprecord":{
                  "token":"3f85d32c6ce9bdd61ebe1f4ca47d82b90ff6c07ee37e2115d2347fe79a06f62d",
                  "merkle":"",
                  "signature":""
               }
            }
         ]
      }
   ]
}

Copy link
Member

@lukebp lukebp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time figuring out what the difference is between these two routes. What's the reasoning for having two routes instead of one?

Also, please don't stack your PRs, i.e. include the batch proposal route in this PR. It makes it harder to review and will mess up the github statistics.

@alexlyp
Copy link
Member Author

alexlyp commented Jul 6, 2020

Summary gives brief information for all proposals that have been billed against name, token and billed amount. This would be used for a basic list/display for the admin.

Details populates the actual line item information for further information when the admin would click on an individual proposal in the listing described above.

10-4 on removing the batch proposal fix in this PR. Will move that over to a new one.

@@ -992,3 +994,27 @@ type CastVoteReply struct {
Error string `json:"error"` // Error status message
ErrorStatus cmsplugin.ErrorStatusT `json:"errorstatus,omitempty"` // Error status code
}

type ProposalBillingSummary struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I noticed that there's this struct defined but it doesn't seem like I can send start and end params (at least it's not documented).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops sorry that was an early addition and forgot to remove. Thanks for pointing out. Removed.

@alexlyp alexlyp requested a review from lukebp July 13, 2020 17:38
}

// ProposalBillingSummaryReply returns an array of proposal spending given the
// time parameters that were given in the request.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out of date.

politeiawww/api/cms/v1/v1.go Show resolved Hide resolved
@@ -395,7 +395,9 @@ func (c *cockroachdb) InvoicesByLineItemsProposalToken(token string) ([]*databas
invoices.month,
invoices.year,
invoices.user_id,
invoices.public_key,
invoices.public_key,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace tabs with spaces so its aligned.

Copy link
Member

@lukebp lukebp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@marcopeereboom will want to ok this.

@alexlyp
Copy link
Member Author

alexlyp commented Jul 15, 2020

OK @marcopeereboom, pagination added.

@@ -931,6 +931,17 @@ func (p *politeiawww) handleStartVoteDCC(w http.ResponseWriter, r *http.Request)
func (p *politeiawww) handlePassThroughTokenInventory(w http.ResponseWriter, r *http.Request) {
log.Tracef("handlePassThroughTokenInventory")

data, err := p.tokenInventoryPassthrough()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a thing anymore, right? 1242 changed it?

@@ -970,6 +978,70 @@ func (p *politeiawww) handlePassThroughBatchProposals(w http.ResponseWriter, r *
util.RespondRaw(w, http.StatusOK, data)
}

func (p *politeiawww) proposalDetails(prop string) ([]byte, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use 1242.

politeiawww/api/cms/v1/v1.go Show resolved Hide resolved
politeiawww/api/cms/v1/api.md Outdated Show resolved Hide resolved
politeiawww/api/cms/v1/api.md Outdated Show resolved Hide resolved
Copy link
Member

@lukebp lukebp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@alexlyp alexlyp merged commit c2a8f14 into decred:master Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants