Skip to content

Commit

Permalink
added new tables
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Apr 23, 2024
1 parent 4ecd700 commit cf3e62a
Show file tree
Hide file tree
Showing 11 changed files with 573 additions and 437 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/frontend-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ jobs:
chmod 777 -R ./lnd;
chmod 777 -R ./proxy;
chmod 777 -R ./cln;
- name: Check for NODES
uses: nick-fields/retry@v2
with:
with:
timeout_minutes: 10
max_attempts: 3
command: |
Expand All @@ -53,12 +53,12 @@ jobs:
docker logs dave.sphinx
docker wait stack_relaysetup_1
cat stack/relay/NODES.json;
- name: Copy Node.json
uses: canastro/copy-file-action@master
with:
source: 'stack/relay/NODES.json'
target: 'tribes-frontend/cypress/fixtures/nodes.json'
source: "stack/relay/NODES.json"
target: "tribes-frontend/cypress/fixtures/nodes.json"

- name: Install Frontend Dependencies
working-directory: ./tribes-frontend
Expand All @@ -73,14 +73,14 @@ jobs:
run: |
sleep 20
yarn run cypress:run
- name: Upload Cypress logs
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress-logs
path: tribes-frontend/cypress/videos

- name: Stop Stack
working-directory: ./stack
run: docker-compose down
run: docker-compose down
73 changes: 39 additions & 34 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ func (db database) GetFilterStatusCount() FilterStattuCount {
return ms
}

func (db database) GetWorkspaceBounties(r *http.Request, workspace_uuid string) []Bounty {
func (db database) GetWorkspaceBounties(r *http.Request, workspace_uuid string) []NewBounty {
keys := r.URL.Query()
tags := keys.Get("tags") // this is a string of tags separated by commas
offset, limit, sortBy, direction, search := utils.GetPaginationParams(r)
Expand All @@ -598,7 +598,7 @@ func (db database) GetWorkspaceBounties(r *http.Request, workspace_uuid string)
languageArray := strings.Split(languages, ",")
languageLength := len(languageArray)

ms := []Bounty{}
ms := []NewBounty{}

orderQuery := ""
limitQuery := ""
Expand Down Expand Up @@ -747,7 +747,7 @@ func (db database) GetWorkspaceBountiesCount(r *http.Request, workspace_uuid str
return count
}

func (db database) GetAssignedBounties(r *http.Request) ([]Bounty, error) {
func (db database) GetAssignedBounties(r *http.Request) ([]NewBounty, error) {
offset, limit, sortBy, direction, _ := utils.GetPaginationParams(r)
uuid := chi.URLParam(r, "uuid")
person := db.GetPersonByUuid(uuid)
Expand Down Expand Up @@ -788,15 +788,15 @@ func (db database) GetAssignedBounties(r *http.Request) ([]Bounty, error) {
limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset)
}

ms := []Bounty{}
ms := []NewBounty{}

query := `SELECT * FROM public.bounty WHERE assignee = '` + pubkey + `' AND show != false`
allQuery := query + " " + statusQuery + " " + orderQuery + " " + limitQuery
err := db.db.Raw(allQuery).Find(&ms).Error
return ms, err
}

func (db database) GetCreatedBounties(r *http.Request) ([]Bounty, error) {
func (db database) GetCreatedBounties(r *http.Request) ([]NewBounty, error) {
offset, limit, sortBy, direction, _ := utils.GetPaginationParams(r)
uuid := chi.URLParam(r, "uuid")
person := db.GetPersonByUuid(uuid)
Expand Down Expand Up @@ -838,7 +838,7 @@ func (db database) GetCreatedBounties(r *http.Request) ([]Bounty, error) {
limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset)
}

ms := []Bounty{}
ms := []NewBounty{}

query := `SELECT * FROM public.bounty WHERE owner_id = '` + pubkey + `'`
allQuery := query + " " + statusQuery + " " + orderQuery + " " + limitQuery
Expand All @@ -847,8 +847,8 @@ func (db database) GetCreatedBounties(r *http.Request) ([]Bounty, error) {
return ms, err
}

func (db database) GetBountyById(id string) ([]Bounty, error) {
ms := []Bounty{}
func (db database) GetBountyById(id string) ([]NewBounty, error) {
ms := []NewBounty{}
err := db.db.Raw(`SELECT * FROM public.bounty WHERE id = '` + id + `'`).Find(&ms).Error
return ms, err
}
Expand Down Expand Up @@ -1117,8 +1117,8 @@ func (db database) GetBountyIndexById(id string) int64 {
return index
}

func (db database) GetBountyDataByCreated(created string) ([]Bounty, error) {
ms := []Bounty{}
func (db database) GetBountyDataByCreated(created string) ([]NewBounty, error) {
ms := []NewBounty{}
err := db.db.Raw(`SELECT * FROM public.bounty WHERE created = '` + created + `'`).Find(&ms).Error
return ms, err
}
Expand All @@ -1128,25 +1128,30 @@ func (db database) AddBounty(b Bounty) (Bounty, error) {
return b, nil
}

func (db database) GetAllBounties(r *http.Request) []Bounty {
func (db database) GetAllBounties(r *http.Request) []NewBounty {
keys := r.URL.Query()
tags := keys.Get("tags") // this is a string of tags separated by commas
offset, limit, sortBy, direction, search := utils.GetPaginationParams(r)
open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
orgUuid := keys.Get("workspace_uuid")
orgUuid := keys.Get("org_uuid")
workspaceUuid := keys.Get("workspace_uuid")
languages := keys.Get("languages")
languageArray := strings.Split(languages, ",")
languageLength := len(languageArray)

ms := []Bounty{}
if workspaceUuid != "" && orgUuid != "" {
workspaceUuid = orgUuid
}

ms := []NewBounty{}

orderQuery := ""
limitQuery := ""
searchQuery := ""
orgQuery := ""
workspaceQuery := ""
languageQuery := ""

if sortBy != "" && direction != "" {
Expand Down Expand Up @@ -1183,8 +1188,8 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {
statusQuery = ""
}

if orgUuid != "" {
orgQuery = "AND workspace_uuid = '" + orgUuid + "'"
if workspaceUuid != "" {
workspaceQuery = "AND workspace_uuid = '" + workspaceUuid + "'"
}
if languageLength > 0 {
langs := ""
Expand All @@ -1202,7 +1207,7 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {

query := "SELECT * FROM public.bounty WHERE show != false"

allQuery := query + " " + statusQuery + " " + searchQuery + " " + orgQuery + " " + languageQuery + " " + orderQuery + " " + limitQuery
allQuery := query + " " + statusQuery + " " + searchQuery + " " + workspaceQuery + " " + languageQuery + " " + orderQuery + " " + limitQuery

theQuery := db.db.Raw(allQuery)

Expand All @@ -1219,9 +1224,9 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {
return ms
}

func (db database) CreateOrEditBounty(b Bounty) (Bounty, error) {
func (db database) CreateOrEditBounty(b NewBounty) (NewBounty, error) {
if b.OwnerID == "" {
return Bounty{}, errors.New("no pub key")
return NewBounty{}, errors.New("no pub key")
}

if db.db.Model(&b).Where("id = ? OR owner_id = ? AND created = ?", b.ID, b.OwnerID, b.Created).Updates(&b).RowsAffected == 0 {
Expand All @@ -1230,14 +1235,14 @@ func (db database) CreateOrEditBounty(b Bounty) (Bounty, error) {
return b, nil
}

func (db database) UpdateBountyNullColumn(b Bounty, column string) Bounty {
func (db database) UpdateBountyNullColumn(b NewBounty, column string) NewBounty {
columnMap := make(map[string]interface{})
columnMap[column] = ""
db.db.Model(&b).Where("created = ?", b.Created).UpdateColumns(&columnMap)
return b
}

func (db database) UpdateBountyBoolColumn(b Bounty, column string) Bounty {
func (db database) UpdateBountyBoolColumn(b NewBounty, column string) NewBounty {
columnMap := make(map[string]interface{})
columnMap[column] = false
db.db.Model(&b).Select(column).UpdateColumns(columnMap)
Expand All @@ -1250,32 +1255,32 @@ func (db database) DeleteBounty(pubkey string, created string) (Bounty, error) {
return m, nil
}

func (db database) GetBountyByCreated(created uint) (Bounty, error) {
b := Bounty{}
func (db database) GetBountyByCreated(created uint) (NewBounty, error) {
b := NewBounty{}
err := db.db.Where("created", created).Find(&b).Error
return b, err
}

func (db database) GetBounty(id uint) Bounty {
b := Bounty{}
func (db database) GetBounty(id uint) NewBounty {
b := NewBounty{}
db.db.Where("id", id).Find(&b)
return b
}

func (db database) UpdateBounty(b Bounty) (Bounty, error) {
func (db database) UpdateBounty(b NewBounty) (NewBounty, error) {
db.db.Where("created", b.Created).Updates(&b)
return b, nil
}

func (db database) UpdateBountyPayment(b Bounty) (Bounty, error) {
func (db database) UpdateBountyPayment(b NewBounty) (NewBounty, error) {
db.db.Model(&b).Where("created", b.Created).Updates(map[string]interface{}{
"paid": b.Paid,
})
db.db.Model(&b).Where("created", b.Created).Updates(b)
return b, nil
}

func (db database) UpdateBountyCompleted(b Bounty) (Bounty, error) {
func (db database) UpdateBountyCompleted(b NewBounty) (NewBounty, error) {
db.db.Model(&b).Where("created", b.Created).Updates(map[string]interface{}{
"completed": b.Completed,
})
Expand Down Expand Up @@ -1676,20 +1681,20 @@ func GetLeaderData(arr []LeaderData, key string) (int, int) {
return found, index
}

func (db database) GetInvoice(payment_request string) InvoiceList {
ms := InvoiceList{}
func (db database) GetInvoice(payment_request string) NewInvoiceList {
ms := NewInvoiceList{}
db.db.Where("payment_request = ?", payment_request).Find(&ms)
return ms
}

func (db database) UpdateInvoice(payment_request string) InvoiceList {
ms := InvoiceList{}
db.db.Model(&InvoiceList{}).Where("payment_request = ?", payment_request).Update("status", true)
func (db database) UpdateInvoice(payment_request string) NewInvoiceList {
ms := NewInvoiceList{}
db.db.Model(&NewInvoiceList{}).Where("payment_request = ?", payment_request).Update("status", true)
ms.Status = true
return ms
}

func (db database) AddInvoice(invoice InvoiceList) InvoiceList {
func (db database) AddInvoice(invoice NewInvoiceList) NewInvoiceList {
db.db.Create(&invoice)
return invoice
}
Expand Down
48 changes: 24 additions & 24 deletions db/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ type Database interface {
GetListedPosts(r *http.Request) ([]PeopleExtra, error)
GetUserBountiesCount(personKey string, tabType string) int64
GetBountiesCount(r *http.Request) int64
GetWorkspaceBounties(r *http.Request, workspace_uuid string) []Bounty
GetWorkspaceBounties(r *http.Request, workspace_uuid string) []NewBounty
GetWorkspaceBountiesCount(r *http.Request, workspace_uuid string) int64
GetAssignedBounties(r *http.Request) ([]Bounty, error)
GetCreatedBounties(r *http.Request) ([]Bounty, error)
GetBountyById(id string) ([]Bounty, error)
GetAssignedBounties(r *http.Request) ([]NewBounty, error)
GetCreatedBounties(r *http.Request) ([]NewBounty, error)
GetBountyById(id string) ([]NewBounty, error)
GetNextBountyByCreated(r *http.Request) (uint, error)
GetPreviousBountyByCreated(r *http.Request) (uint, error)
GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error)
GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, error)
GetBountyIndexById(id string) int64
GetBountyDataByCreated(created string) ([]Bounty, error)
GetBountyDataByCreated(created string) ([]NewBounty, error)
AddBounty(b Bounty) (Bounty, error)
GetAllBounties(r *http.Request) []Bounty
CreateOrEditBounty(b Bounty) (Bounty, error)
UpdateBountyNullColumn(b Bounty, column string) Bounty
UpdateBountyBoolColumn(b Bounty, column string) Bounty
GetAllBounties(r *http.Request) []NewBounty
CreateOrEditBounty(b NewBounty) (NewBounty, error)
UpdateBountyNullColumn(b NewBounty, column string) NewBounty
UpdateBountyBoolColumn(b NewBounty, column string) NewBounty
DeleteBounty(pubkey string, created string) (Bounty, error)
GetBountyByCreated(created uint) (Bounty, error)
GetBounty(id uint) Bounty
UpdateBounty(b Bounty) (Bounty, error)
UpdateBountyPayment(b Bounty) (Bounty, error)
GetBountyByCreated(created uint) (NewBounty, error)
GetBounty(id uint) NewBounty
UpdateBounty(b NewBounty) (NewBounty, error)
UpdateBountyPayment(b NewBounty) (NewBounty, error)
GetListedOffers(r *http.Request) ([]PeopleExtra, error)
UpdateBot(uuid string, u map[string]interface{}) bool
GetAllTribes() []Tribe
Expand Down Expand Up @@ -99,21 +99,21 @@ type Database interface {
GetUserCreatedWorkspaces(pubkey string) []Workspace
GetUserAssignedWorkspaces(pubkey string) []WorkspaceUsers
AddBudgetHistory(budget BudgetHistory) BudgetHistory
CreateWorkspaceBudget(budget BountyBudget) BountyBudget
UpdateWorkspaceBudget(budget BountyBudget) BountyBudget
GetPaymentHistoryByCreated(created *time.Time, workspace_uuid string) PaymentHistory
GetWorkspaceBudget(workspace_uuid string) BountyBudget
CreateWorkspaceBudget(budget NewBountyBudget) NewBountyBudget
UpdateWorkspaceBudget(budget NewBountyBudget) NewBountyBudget
GetPaymentHistoryByCreated(created *time.Time, workspace_uuid string) NewPaymentHistory
GetWorkspaceBudget(workspace_uuid string) NewBountyBudget
GetWorkspaceStatusBudget(workspace_uuid string) StatusBudget
GetWorkspaceBudgetHistory(workspace_uuid string) []BudgetHistoryData
AddAndUpdateBudget(invoice InvoiceList) PaymentHistory
AddAndUpdateBudget(invoice NewInvoiceList) NewPaymentHistory
WithdrawBudget(sender_pubkey string, workspace_uuid string, amount uint)
AddPaymentHistory(payment PaymentHistory) PaymentHistory
GetPaymentHistory(workspace_uuid string, r *http.Request) []PaymentHistory
GetInvoice(payment_request string) InvoiceList
GetWorkspaceInvoices(workspace_uuid string) []InvoiceList
AddPaymentHistory(payment NewPaymentHistory) NewPaymentHistory
GetPaymentHistory(workspace_uuid string, r *http.Request) []NewPaymentHistory
GetInvoice(payment_request string) NewInvoiceList
GetWorkspaceInvoices(workspace_uuid string) []NewInvoiceList
GetWorkspaceInvoicesCount(workspace_uuid string) int64
UpdateInvoice(payment_request string) InvoiceList
AddInvoice(invoice InvoiceList) InvoiceList
UpdateInvoice(payment_request string) NewInvoiceList
AddInvoice(invoice NewInvoiceList) NewInvoiceList
AddUserInvoiceData(userData UserInvoiceData) UserInvoiceData
GetUserInvoiceData(payment_request string) UserInvoiceData
DeleteUserInvoiceData(payment_request string) UserInvoiceData
Expand Down
Loading

0 comments on commit cf3e62a

Please sign in to comment.