Skip to content

Commit

Permalink
[FIX] Assign Bounty and Null error caused by StringArray (#553)
Browse files Browse the repository at this point in the history
* fixed null error and assign tickets

* changed to extractedPubKey

* changed Property map function
  • Loading branch information
elraphty authored May 24, 2023
1 parent 42fc0ba commit e6d5aca
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 78 deletions.
5 changes: 4 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/go-chi/chi"
"github.com/lib/pq"
_ "github.com/lib/pq"
"github.com/rs/xid"

Expand Down Expand Up @@ -829,8 +830,10 @@ func (db database) CreateLnUser(lnKey string) (Person, error) {
p.OwnerAlias = lnKey
p.UniqueName, _ = PersonUniqueNameFromName(p.OwnerAlias)
p.Created = &now
p.Tags = StringArray{}
p.Tags = pq.StringArray{}
p.Uuid = xid.New().String()
p.Extras = make(map[string]interface{})
p.GithubIssues = make(map[string]interface{})

db.db.Create(&p)
}
Expand Down
145 changes: 72 additions & 73 deletions db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,66 @@ import (

// Tribe struct
type Tribe struct {
UUID string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
OwnerAlias string `json:"owner_alias"`
GroupKey string `json:"group_key"`
Name string `json:"name"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags StringArray `gorm:"type:text[]" json:"tags"`
Img string `json:"img"`
PriceToJoin int64 `json:"price_to_join"`
PricePerMessage int64 `json:"price_per_message"`
EscrowAmount int64 `json:"escrow_amount"`
EscrowMillis int64 `json:"escrow_millis"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
MemberCount uint64 `json:"member_count"`
Unlisted bool `json:"unlisted"`
Private bool `json:"private"`
Deleted bool `json:"deleted"`
AppURL string `json:"app_url"`
FeedURL string `json:"feed_url"`
FeedType uint64 `json:"feed_type"`
LastActive int64 `json:"last_active"`
Bots string `json:"bots"`
OwnerRouteHint string `json:"owner_route_hint"`
Pin string `json:"pin"`
Preview string `json:"preview"`
ProfileFilters string `json:"profile_filters"` // "twitter,github"
Badges StringArray `gorm:"type:text[]" json:"badges"`
UUID string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
OwnerAlias string `json:"owner_alias"`
GroupKey string `json:"group_key"`
Name string `json:"name"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags pq.StringArray `gorm:"type:text[]" json:"tags"`
Img string `json:"img"`
PriceToJoin int64 `json:"price_to_join"`
PricePerMessage int64 `json:"price_per_message"`
EscrowAmount int64 `json:"escrow_amount"`
EscrowMillis int64 `json:"escrow_millis"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
MemberCount uint64 `json:"member_count"`
Unlisted bool `json:"unlisted"`
Private bool `json:"private"`
Deleted bool `json:"deleted"`
AppURL string `json:"app_url"`
FeedURL string `json:"feed_url"`
FeedType uint64 `json:"feed_type"`
LastActive int64 `json:"last_active"`
Bots string `json:"bots"`
OwnerRouteHint string `json:"owner_route_hint"`
Pin string `json:"pin"`
Preview string `json:"preview"`
ProfileFilters string `json:"profile_filters"` // "twitter,github"
Badges pq.StringArray `gorm:"type:text[]" json:"badges"`
}

// Bot struct
type Bot struct {
UUID string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
OwnerAlias string `json:"owner_alias"`
Name string `json:"name"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags StringArray `json:"tags"`
Img string `json:"img"`
PricePerUse int64 `json:"price_per_use"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Unlisted bool `json:"unlisted"`
Deleted bool `json:"deleted"`
MemberCount uint64 `json:"member_count"`
OwnerRouteHint string `json:"owner_route_hint"`
UUID string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
OwnerAlias string `json:"owner_alias"`
Name string `json:"name"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags pq.StringArray `json:"tags"`
Img string `json:"img"`
PricePerUse int64 `json:"price_per_use"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Unlisted bool `json:"unlisted"`
Deleted bool `json:"deleted"`
MemberCount uint64 `json:"member_count"`
OwnerRouteHint string `json:"owner_route_hint"`
}

// Bot struct
type BotRes struct {
UUID string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
Name string `json:"name"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags StringArray `json:"tags"`
Img string `json:"img"`
PricePerUse int64 `json:"price_per_use"`
UUID string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
Name string `json:"name"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags pq.StringArray `json:"tags"`
Img string `json:"img"`
PricePerUse int64 `json:"price_per_use"`
}

// for bot pricing info
Expand Down Expand Up @@ -105,26 +105,26 @@ func (PersonInShort) TableName() string {

// Person struct
type Person struct {
ID uint `json:"id"`
Uuid string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
OwnerAlias string `json:"owner_alias"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags StringArray `gorm:"type:text[]" json:"tags" null`
Img string `json:"img"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Unlisted bool `json:"unlisted"`
Deleted bool `json:"deleted"`
LastLogin int64 `json:"last_login"`
OwnerRouteHint string `json:"owner_route_hint"`
OwnerContactKey string `json:"owner_contact_key"`
PriceToMeet int64 `json:"price_to_meet"`
Extras PropertyMap `json:"extras", type: jsonb not null default '{}'::jsonb`
TwitterConfirmed bool `json:"twitter_confirmed"`
GithubIssues PropertyMap `json:"github_issues", type: jsonb not null default '{}'::jsonb`
NewTicketTime int64 `json:"new_ticket_time", gorm: "-:all"`
ID uint `json:"id"`
Uuid string `json:"uuid"`
OwnerPubKey string `json:"owner_pubkey"`
OwnerAlias string `json:"owner_alias"`
UniqueName string `json:"unique_name"`
Description string `json:"description"`
Tags pq.StringArray `gorm:"type:text[]" json:"tags" null`
Img string `json:"img"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Unlisted bool `json:"unlisted"`
Deleted bool `json:"deleted"`
LastLogin int64 `json:"last_login"`
OwnerRouteHint string `json:"owner_route_hint"`
OwnerContactKey string `json:"owner_contact_key"`
PriceToMeet int64 `json:"price_to_meet"`
Extras PropertyMap `json:"extras", type: jsonb not null default '{}'::jsonb`
TwitterConfirmed bool `json:"twitter_confirmed"`
GithubIssues PropertyMap `json:"github_issues", type: jsonb not null default '{}'::jsonb`
NewTicketTime int64 `json:"new_ticket_time", gorm: "-:all"`
}

type GormDataTypeInterface interface {
Expand Down Expand Up @@ -322,7 +322,6 @@ type PropertyMap map[string]interface{}
func (p PropertyMap) Value() (driver.Value, error) {
b := new(bytes.Buffer)
err := json.NewEncoder(b).Encode(p)

return b, err
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/people/utils/assignBounty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function AssignBounty(props: ConnectCardProps) {
}

const generateInvoice = async () => {
const data = await main.getLnInvoice({
await main.getLnInvoice({
amount: 200 * bountyHours,
memo: '',
owner_pubkey: person?.owner_pubkey ?? '',
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function AssignBounty(props: ConnectCardProps) {
main.getPeopleWanteds({ page: 1, resetPage: true });
}

if (count >= invoicePollTarget * pollMinutes) {
if (count >= invoicePollTarget) {
// close modal
props.dismiss();
main.setLnInvoice('');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Invoice(props: {

return (
<div style={{ marginTop: '30px' }}>
{timeLeft.seconds || (timeLeft.minutes && !props.dataStatus) ? (
{timeLeft.seconds >= 0 || (timeLeft.minutes >= 0 && !props.dataStatus) ? (
<InvoiceWrap>
<CountDownTimerWrap>
<CountDownText>Invoice expires in a minute</CountDownText>
Expand Down
6 changes: 5 additions & 1 deletion handlers/invoiceCron.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func InitInvoiceCron() {
"extras": b,
})

// Delete the index from tje store array list and reset the store
// Delete the index from the store array list and reset the store
newInvoiceList := append(invoiceList[:index], invoiceList[index+1:]...)
db.Store.SetInvoiceCache(newInvoiceList)
}
Expand Down Expand Up @@ -191,6 +191,10 @@ func InitInvoiceCron() {
db.DB.UpdatePerson(p.ID, map[string]interface{}{
"extras": b,
})

// Delete the index from the store array list and reset the store
newInvoiceList := append(invoiceList[:index], invoiceList[index+1:]...)
db.Store.SetInvoiceCache(newInvoiceList)
}
}
}
Expand Down

0 comments on commit e6d5aca

Please sign in to comment.