Browse Source

Rename some variables

master
Jared 1 year ago
parent
commit
42e01a7cd3
9 changed files with 50 additions and 38 deletions
  1. +2
    -1
      data/context.go
  2. +2
    -1
      endpoints/closerewardfund.go
  3. +4
    -3
      endpoints/contributionstream.go
  4. +2
    -1
      endpoints/createqueue.go
  5. +3
    -2
      endpoints/createrewardfund.go
  6. +6
    -2
      endpoints/getqueuemembers.go
  7. +9
    -8
      endpoints/getrewardfund.go
  8. +4
    -3
      endpoints/login.go
  9. +18
    -17
      endpoints/submitfund.go

+ 2
- 1
data/context.go View File

@@ -2,10 +2,11 @@ package data


import ( import (
"fmt" "fmt"
"time"

"github.com/spf13/viper" "github.com/spf13/viper"
"gorm.io/driver/postgres" "gorm.io/driver/postgres"
"gorm.io/gorm" "gorm.io/gorm"
"time"
) )


type ModelBase struct { type ModelBase struct {


+ 2
- 1
endpoints/closerewardfund.go View File

@@ -2,9 +2,10 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
"net/http"

"github.com/imosed/signet/auth" "github.com/imosed/signet/auth"
. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"net/http"
) )


type CloseRewardFundRequest struct { type CloseRewardFundRequest struct {


+ 4
- 3
endpoints/contributionstream.go View File

@@ -2,6 +2,10 @@ package endpoints


import ( import (
"fmt" "fmt"
"net/http"
"strconv"
"strings"

"github.com/gorilla/websocket" "github.com/gorilla/websocket"
. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"github.com/spf13/viper" "github.com/spf13/viper"
@@ -9,9 +13,6 @@ import (
"github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/protocols/horizon/operations" "github.com/stellar/go/protocols/horizon/operations"
"golang.org/x/net/context" "golang.org/x/net/context"
"net/http"
"strconv"
"strings"
) )


var upgrader = websocket.Upgrader{ var upgrader = websocket.Upgrader{


+ 2
- 1
endpoints/createqueue.go View File

@@ -2,8 +2,9 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
. "github.com/imosed/signet/data"
"net/http" "net/http"

. "github.com/imosed/signet/data"
) )


type CreateQueueRequest struct { type CreateQueueRequest struct {


+ 3
- 2
endpoints/createrewardfund.go View File

@@ -3,12 +3,13 @@ package endpoints
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http"
"strconv"

"github.com/imosed/signet/auth" "github.com/imosed/signet/auth"
. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon"
"net/http"
"strconv"
) )


type CreateRewardFundRequest struct { type CreateRewardFundRequest struct {


+ 6
- 2
endpoints/getqueuemembers.go View File

@@ -2,13 +2,16 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
. "github.com/imosed/signet/data"
"net/http" "net/http"

. "github.com/imosed/signet/data"
) )


type QueueMember struct { type QueueMember struct {
ID uint `json:"id"`
Asset string `json:"asset"` Asset string `json:"asset"`
Title string `json:"title"` Title string `json:"title"`
Order int `json:"order"`
} }


type GetQueueMembersRequest struct { type GetQueueMembersRequest struct {
@@ -27,7 +30,8 @@ func GetQueueMembers(w http.ResponseWriter, r *http.Request) {
} }


var members []QueueMember var members []QueueMember
Db.Table("queue_orders qo").Select("reward_fund_id, asset, title").Where("queue_id = ?", req.ID).
Db.Table("queue_orders qo").Select("rf.id, asset, title, qo.order").
Where("queue_id = ?", req.ID).
Joins("inner join reward_funds rf on qo.reward_fund_id = rf.id"). Joins("inner join reward_funds rf on qo.reward_fund_id = rf.id").
Scan(&members) Scan(&members)




+ 9
- 8
endpoints/getrewardfund.go View File

@@ -2,10 +2,11 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
. "github.com/imosed/signet/data"
"gorm.io/gorm/clause"
"net/http" "net/http"
"time" "time"

. "github.com/imosed/signet/data"
"gorm.io/gorm/clause"
) )


type Total struct { type Total struct {
@@ -13,7 +14,7 @@ type Total struct {
} }


type GetRewardFundRequest struct { type GetRewardFundRequest struct {
Id uint `json:"id"`
ID uint `json:"id"`
ConsolidateContributions bool `json:"consolidateContributions"` ConsolidateContributions bool `json:"consolidateContributions"`
} }


@@ -35,7 +36,7 @@ func GetRewardFund(resp http.ResponseWriter, req *http.Request) {
panic("Could not read requested fund") panic("Could not read requested fund")
} }


found := Db.Preload(clause.Associations).Find(&fund, requestedFund.Id).RowsAffected
found := Db.Preload(clause.Associations).Find(&fund, requestedFund.ID).RowsAffected
if found == 0 { if found == 0 {
resp.WriteHeader(404) resp.WriteHeader(404)
return return
@@ -79,7 +80,7 @@ func GetRewardFund(resp http.ResponseWriter, req *http.Request) {
} }


type GetContributionsRequest struct { type GetContributionsRequest struct {
Id uint `json:"id"`
ID uint `json:"id"`
Offset int `json:"offset"` Offset int `json:"offset"`
ForDate string `json:"forDate"` ForDate string `json:"forDate"`
ConsolidateContributions bool `json:"consolidateContributions"` ConsolidateContributions bool `json:"consolidateContributions"`
@@ -101,10 +102,10 @@ func GetContributions(w http.ResponseWriter, r *http.Request) {
} }


var resp GetContributionsResponse var resp GetContributionsResponse
baseQuery := Db.Table("contributions").Where("reward_fund_id = ?", req.Id).Offset(req.Offset).Limit(30)
baseCount := Db.Table("contributions").Where("reward_fund_id = ?", req.Id)
baseQuery := Db.Table("contributions").Where("reward_fund_id = ?", req.ID).Offset(req.Offset).Limit(30)
baseCount := Db.Table("contributions").Where("reward_fund_id = ?", req.ID)


Db.Table("contributions").Select("distinct on (created_at::TIMESTAMP::DATE) created_at").Where("reward_fund_id = ?", req.Id).Scan(&resp.Dates)
Db.Table("contributions").Select("distinct on (created_at::TIMESTAMP::DATE) created_at").Where("reward_fund_id = ?", req.ID).Scan(&resp.Dates)


if req.ForDate == "" { if req.ForDate == "" {
if req.ConsolidateContributions { if req.ConsolidateContributions {


+ 4
- 3
endpoints/login.go View File

@@ -2,12 +2,13 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
"net/http"
"time"

"github.com/golang-jwt/jwt/v4" "github.com/golang-jwt/jwt/v4"
"github.com/imosed/signet/auth" "github.com/imosed/signet/auth"
. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"github.com/spf13/viper" "github.com/spf13/viper"
"net/http"
"time"
) )


type LoginResponse struct { type LoginResponse struct {
@@ -22,7 +23,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
} }


var userData struct { var userData struct {
Id uint
ID uint
Password string Password string
Privileges uint Privileges uint
} }


+ 18
- 17
endpoints/submitfund.go View File

@@ -3,16 +3,17 @@ package endpoints
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http"

. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon"
"net/http"
) )


var client = horizonclient.DefaultTestNetClient var client = horizonclient.DefaultTestNetClient


type SubmitFundRequest struct { type SubmitFundRequest struct {
FundId uint `json:"fundId"`
FundID uint `json:"fundId"`
} }


func SubmitFund(w http.ResponseWriter, r *http.Request) { func SubmitFund(w http.ResponseWriter, r *http.Request) {
@@ -23,12 +24,12 @@ func SubmitFund(w http.ResponseWriter, r *http.Request) {
} }


var fund RewardFund var fund RewardFund
Db.Find(&fund, req.FundId)
Db.Find(&fund, req.FundID)


//source := keypair.MustParseFull(fund.FundWallet)
//sourceReq := horizonclient.AccountRequest{AccountID: source.Address()}
//var sourceAcct horizon.Account
//sourceAcct, err = client.AccountDetail(sourceReq)
// source := keypair.MustParseFull(fund.FundWallet)
// sourceReq := horizonclient.AccountRequest{AccountID: source.Address()}
// var sourceAcct horizon.Account
// sourceAcct, err = client.AccountDetail(sourceReq)


offerReq := horizonclient.OfferRequest{ offerReq := horizonclient.OfferRequest{
Selling: fmt.Sprintf("%s:%s", fund.Asset, fund.IssuerWallet), Selling: fmt.Sprintf("%s:%s", fund.Asset, fund.IssuerWallet),
@@ -45,8 +46,8 @@ func SubmitFund(w http.ResponseWriter, r *http.Request) {
} }
} }


//var tx *txnbuild.Transaction
//tx, err = txnbuild.NewTransaction(
// var tx *txnbuild.Transaction
// tx, err = txnbuild.NewTransaction(
// txnbuild.TransactionParams{ // txnbuild.TransactionParams{
// SourceAccount: &sourceAcct, // SourceAccount: &sourceAcct,
// IncrementSequenceNum: true, // IncrementSequenceNum: true,
@@ -69,20 +70,20 @@ func SubmitFund(w http.ResponseWriter, r *http.Request) {
// TimeBounds: txnbuild.NewInfiniteTimeout(), // TODO: change from infinite // TimeBounds: txnbuild.NewInfiniteTimeout(), // TODO: change from infinite
// }, // },
// }) // })
//if err != nil {
// if err != nil {
// panic("Could not submit reward fund") // panic("Could not submit reward fund")
//}
// }
// //
//tx, err = tx.Sign(network.TestNetworkPassphrase, source)
//if err != nil {
// tx, err = tx.Sign(network.TestNetworkPassphrase, source)
// if err != nil {
// panic("Could not submit fund") // panic("Could not submit fund")
//}
// }
// //
//var response horizon.Transaction
//response, err = client.SubmitTransaction(tx)
// var response horizon.Transaction
// response, err = client.SubmitTransaction(tx)


var resp SuccessResponse var resp SuccessResponse
//resp.Success = response.Successful
// resp.Success = response.Successful


err = json.NewEncoder(w).Encode(resp) err = json.NewEncoder(w).Encode(resp)
if err != nil { if err != nil {


Loading…
Cancel
Save