diff --git a/README.md b/README.md index 2f7df0083..d71db6f29 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ packages: We are currently using `gopkg.in/go-playground/validator.v9` for validation, to validate a struct add the `validate` property to it ```golang -type Organization struct { +type Workspace struct { Name string `gorm:"unique;not null" json:"name" validate:"required"` Website string `json:"website" validate:"omitempty,uri"` Github string `json:"github" validate:"omitempty,uri"` diff --git a/db/config.go b/db/config.go index d3d7c4425..d3ad61383 100644 --- a/db/config.go +++ b/db/config.go @@ -11,16 +11,16 @@ import ( ) type database struct { - db *gorm.DB - getOrganizationByUuid func(uuid string) Organization - getUserRoles func(uuid string, pubkey string) []UserRoles + db *gorm.DB + getWorkspaceByUuid func(uuid string) Organization + getUserRoles func(uuid string, pubkey string) []UserRoles } func NewDatabaseConfig(db *gorm.DB) *database { return &database{ - db: db, - getOrganizationByUuid: DB.GetOrganizationByUuid, - getUserRoles: DB.GetUserRoles, + db: db, + getWorkspaceByUuid: DB.GetWorkspaceByUuid, + getUserRoles: DB.GetUserRoles, } } @@ -219,7 +219,7 @@ func (db database) ConvertMetricsBountiesToMap(metricsCsv []MetricsBountyCsv) [] metricMap := make(map[string]interface{}) metricMap["DatePosted"] = m.DatePosted - metricMap["Organization"] = m.Organization + metricMap["Workspace"] = m.Organization metricMap["BountyAmount"] = m.BountyAmount metricMap["Provider"] = m.Provider metricMap["Hunter"] = m.Hunter @@ -263,7 +263,7 @@ func CheckUser(userRoles []UserRoles, pubkey string) bool { } func UserHasAccess(pubKeyFromAuth string, uuid string, role string) bool { - org := DB.GetOrganizationByUuid(uuid) + org := DB.GetWorkspaceByUuid(uuid) var hasRole bool = false if pubKeyFromAuth != org.OwnerPubKey { userRoles := DB.GetUserRoles(uuid, pubKeyFromAuth) @@ -274,7 +274,7 @@ func UserHasAccess(pubKeyFromAuth string, uuid string, role string) bool { } func (db database) UserHasAccess(pubKeyFromAuth string, uuid string, role string) bool { - org := db.getOrganizationByUuid(uuid) + org := db.getWorkspaceByUuid(uuid) var hasRole bool = false if pubKeyFromAuth != org.OwnerPubKey { userRoles := db.getUserRoles(uuid, pubKeyFromAuth) @@ -286,7 +286,7 @@ func (db database) UserHasAccess(pubKeyFromAuth string, uuid string, role string func (db database) UserHasManageBountyRoles(pubKeyFromAuth string, uuid string) bool { var manageRolesCount = len(ManageBountiesGroup) - org := db.getOrganizationByUuid(uuid) + org := db.getWorkspaceByUuid(uuid) if pubKeyFromAuth != org.OwnerPubKey { userRoles := db.getUserRoles(uuid, pubKeyFromAuth) diff --git a/db/config_test.go b/db/config_test.go index 1b78d8002..b804fe76d 100644 --- a/db/config_test.go +++ b/db/config_test.go @@ -55,7 +55,7 @@ func TestCheckUser(t *testing.T) { } func TestUserHasAccess(t *testing.T) { - mockGetOrganizationByUuid := func(uuid string) Organization { + mockGetWorkspaceByUuid := func(uuid string) Organization { return Organization{ Uuid: uuid, OwnerPubKey: "org_admin", @@ -71,7 +71,7 @@ func TestUserHasAccess(t *testing.T) { mockDB := &gorm.DB{} databaseConfig := NewDatabaseConfig(mockDB) - databaseConfig.getOrganizationByUuid = mockGetOrganizationByUuid + databaseConfig.getWorkspaceByUuid = mockGetWorkspaceByUuid databaseConfig.getUserRoles = mockGetUserRoles t.Run("Should test that if the user is the admin of an organization returns true", func(t *testing.T) { @@ -103,7 +103,7 @@ func TestUserHasAccess(t *testing.T) { } func TestUserHasManageBountyRoles(t *testing.T) { - mockGetOrganizationByUuid := func(uuid string) Organization { + mockGetWorkspaceByUuid := func(uuid string) Organization { return Organization{ Uuid: uuid, OwnerPubKey: "org_admin", @@ -128,7 +128,7 @@ func TestUserHasManageBountyRoles(t *testing.T) { mockDB := &gorm.DB{} databaseConfig := NewDatabaseConfig(mockDB) - databaseConfig.getOrganizationByUuid = mockGetOrganizationByUuid + databaseConfig.getWorkspaceByUuid = mockGetWorkspaceByUuid databaseConfig.getUserRoles = mockGetUserRoles t.Run("Should test that if the user is the organization admin return true", func(t *testing.T) { diff --git a/db/db.go b/db/db.go index 314dc45fc..0d04078c0 100644 --- a/db/db.go +++ b/db/db.go @@ -573,7 +573,7 @@ func (db database) GetFilterStatusCount() FilterStattuCount { return ms } -func (db database) GetOrganizationBounties(r *http.Request, org_uuid string) []Bounty { +func (db database) GetWorkspaceBounties(r *http.Request, org_uuid string) []Bounty { 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) @@ -656,7 +656,7 @@ func (db database) GetOrganizationBounties(r *http.Request, org_uuid string) []B return ms } -func (db database) GetOrganizationBountiesCount(r *http.Request, org_uuid string) int64 { +func (db database) GetWorkspaceBountiesCount(r *http.Request, org_uuid string) int64 { keys := r.URL.Query() tags := keys.Get("tags") // this is a string of tags separated by commas search := keys.Get("search") @@ -954,7 +954,7 @@ func (db database) GetPreviousBountyByCreated(r *http.Request) (uint, error) { return bountyId, err } -func (db database) GetNextOrganizationBountyByCreated(r *http.Request) (uint, error) { +func (db database) GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error) { created := chi.URLParam(r, "created") uuid := chi.URLParam(r, "uuid") keys := r.URL.Query() @@ -1016,7 +1016,7 @@ func (db database) GetNextOrganizationBountyByCreated(r *http.Request) (uint, er return bountyId, err } -func (db database) GetPreviousOrganizationBountyByCreated(r *http.Request) (uint, error) { +func (db database) GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, error) { created := chi.URLParam(r, "created") uuid := chi.URLParam(r, "uuid") keys := r.URL.Query() @@ -1639,289 +1639,12 @@ func GetLeaderData(arr []LeaderData, key string) (int, int) { return found, index } -func (db database) GetOrganizations(r *http.Request) []Organization { - ms := []Organization{} - offset, limit, sortBy, direction, search := utils.GetPaginationParams(r) - - // return if like owner_alias, unique_name, or equals pubkey - db.db.Offset(offset).Limit(limit).Order(sortBy+" "+direction+" ").Where("LOWER(name) LIKE ?", "%"+search+"%").Where("deleted != ?", false).Find(&ms) - return ms -} - -func (db database) GetOrganizationsCount() int64 { - var count int64 - db.db.Model(&Organization{}).Count(&count) - return count -} - -func (db database) GetOrganizationByUuid(uuid string) Organization { - ms := Organization{} - - db.db.Model(&Organization{}).Where("uuid = ?", uuid).Find(&ms) - - return ms -} - -func (db database) GetOrganizationByName(name string) Organization { - ms := Organization{} - - db.db.Model(&Organization{}).Where("name = ?", name).Find(&ms) - - return ms -} - -func (db database) CreateOrEditOrganization(m Organization) (Organization, error) { - if m.OwnerPubKey == "" { - return Organization{}, errors.New("no pub key") - } - - if db.db.Model(&m).Where("uuid = ?", m.Uuid).Updates(&m).RowsAffected == 0 { - db.db.Create(&m) - } - - return m, nil -} - -func (db database) GetOrganizationUsers(uuid string) ([]OrganizationUsersData, error) { - ms := []OrganizationUsersData{} - - err := db.db.Raw(`SELECT org.org_uuid, org.created as user_created, person.* FROM public.organization_users AS org LEFT OUTER JOIN public.people AS person ON org.owner_pub_key = person.owner_pub_key WHERE org.org_uuid = '` + uuid + `' ORDER BY org.created DESC`).Find(&ms).Error - - return ms, err -} - -func (db database) GetOrganizationUsersCount(uuid string) int64 { - var count int64 - db.db.Model(&OrganizationUsers{}).Where("org_uuid = ?", uuid).Count(&count) - return count -} - -func (db database) GetOrganizationBountyCount(uuid string) int64 { - var count int64 - db.db.Model(&Bounty{}).Where("org_uuid = ?", uuid).Count(&count) - return count -} - -func (db database) GetOrganizationUser(pubkey string, org_uuid string) OrganizationUsers { - ms := OrganizationUsers{} - db.db.Where("org_uuid = ?", org_uuid).Where("owner_pub_key = ?", pubkey).Find(&ms) - return ms -} - -func (db database) CreateOrganizationUser(orgUser OrganizationUsers) OrganizationUsers { - db.db.Create(&orgUser) - - return orgUser -} - -func (db database) DeleteOrganizationUser(orgUser OrganizationUsersData, org string) OrganizationUsersData { - db.db.Where("owner_pub_key = ?", orgUser.OwnerPubKey).Where("org_uuid = ?", org).Delete(&OrganizationUsers{}) - db.db.Where("owner_pub_key = ?", orgUser.OwnerPubKey).Where("org_uuid = ?", org).Delete(&UserRoles{}) - return orgUser -} - -func (db database) GetBountyRoles() []BountyRoles { - ms := []BountyRoles{} - db.db.Find(&ms) - return ms -} - -func (db database) CreateUserRoles(roles []UserRoles, uuid string, pubkey string) []UserRoles { - // delete roles and create new ones - db.db.Where("org_uuid = ?", uuid).Where("owner_pub_key = ?", pubkey).Delete(&UserRoles{}) - db.db.Create(&roles) - - return roles -} - -func (db database) GetUserRoles(uuid string, pubkey string) []UserRoles { - ms := []UserRoles{} - db.db.Where("org_uuid = ?", uuid).Where("owner_pub_key = ?", pubkey).Find(&ms) - return ms -} - -func (db database) GetUserCreatedOrganizations(pubkey string) []Organization { - ms := []Organization{} - db.db.Where("owner_pub_key = ?", pubkey).Where("deleted != ?", true).Find(&ms) - return ms -} - -func (db database) GetUserAssignedOrganizations(pubkey string) []OrganizationUsers { - ms := []OrganizationUsers{} - db.db.Where("owner_pub_key = ?", pubkey).Find(&ms) - return ms -} - -func (db database) AddBudgetHistory(budget BudgetHistory) BudgetHistory { - db.db.Create(&budget) - return budget -} - -func (db database) CreateOrganizationBudget(budget BountyBudget) BountyBudget { - db.db.Create(&budget) - return budget -} - -func (db database) UpdateOrganizationBudget(budget BountyBudget) BountyBudget { - db.db.Model(&BountyBudget{}).Where("org_uuid = ?", budget.OrgUuid).Updates(map[string]interface{}{ - "total_budget": budget.TotalBudget, - }) - return budget -} - -func (db database) GetPaymentHistoryByCreated(created *time.Time, org_uuid string) PaymentHistory { - ms := PaymentHistory{} - db.db.Where("created = ?", created).Where("org_uuid = ? ", org_uuid).Find(&ms) - return ms -} - -func (db database) GetOrganizationBudget(org_uuid string) BountyBudget { - ms := BountyBudget{} - db.db.Where("org_uuid = ?", org_uuid).Find(&ms) - - return ms -} - -func (db database) GetOrganizationStatusBudget(org_uuid string) StatusBudget { - - orgBudget := db.GetOrganizationBudget(org_uuid) - - var openBudget uint - db.db.Model(&Bounty{}).Where("assignee = '' ").Where("paid != true").Select("SUM(price)").Row().Scan(&openBudget) - - var assignedBudget uint - db.db.Model(&Bounty{}).Where("assignee != '' ").Where("paid != true").Select("SUM(price)").Row().Scan(&assignedBudget) - - var completedBudget uint - db.db.Model(&Bounty{}).Where("completed = true ").Where("paid != true").Select("SUM(price)").Row().Scan(&completedBudget) - - statusBudget := StatusBudget{ - OrgUuid: org_uuid, - CurrentBudget: orgBudget.TotalBudget, - OpenBudget: openBudget, - AssignedBudget: assignedBudget, - CompletedBudget: completedBudget, - } - - return statusBudget -} - -func (db database) GetOrganizationBudgetHistory(org_uuid string) []BudgetHistoryData { - budgetHistory := []BudgetHistoryData{} - - db.db.Raw(`SELECT budget.id, budget.org_uuid, budget.amount, budget.created, budget.updated, budget.payment_type, budget.status, budget.sender_pub_key, sender.unique_name AS sender_name FROM public.budget_histories AS budget LEFT OUTER JOIN public.people AS sender ON budget.sender_pub_key = sender.owner_pub_key WHERE budget.org_uuid = '` + org_uuid + `' ORDER BY budget.created DESC`).Find(&budgetHistory) - return budgetHistory -} - -func (db database) AddAndUpdateBudget(invoice InvoiceList) PaymentHistory { - created := invoice.Created - org_uuid := invoice.OrgUuid - - paymentHistory := db.GetPaymentHistoryByCreated(created, org_uuid) - - if paymentHistory.OrgUuid != "" && paymentHistory.Amount != 0 { - paymentHistory.Status = true - db.db.Where("created = ?", created).Where("org_uuid = ? ", org_uuid).Updates(paymentHistory) - - // get organization budget and add payment to total budget - organizationBudget := db.GetOrganizationBudget(org_uuid) - - if organizationBudget.OrgUuid == "" { - now := time.Now() - orgBudget := BountyBudget{ - OrgUuid: org_uuid, - TotalBudget: paymentHistory.Amount, - Created: &now, - Updated: &now, - } - db.CreateOrganizationBudget(orgBudget) - } else { - totalBudget := organizationBudget.TotalBudget - organizationBudget.TotalBudget = totalBudget + paymentHistory.Amount - db.UpdateOrganizationBudget(organizationBudget) - } - } - - return paymentHistory -} - -func (db database) WithdrawBudget(sender_pubkey string, org_uuid string, amount uint) { - // get organization budget and add payment to total budget - organizationBudget := db.GetOrganizationBudget(org_uuid) - totalBudget := organizationBudget.TotalBudget - - newBudget := totalBudget - amount - db.db.Model(&BountyBudget{}).Where("org_uuid = ?", org_uuid).Updates(map[string]interface{}{ - "total_budget": newBudget, - }) - - now := time.Now() - - budgetHistory := PaymentHistory{ - OrgUuid: org_uuid, - Amount: amount, - Status: true, - PaymentType: "withdraw", - Created: &now, - Updated: &now, - SenderPubKey: sender_pubkey, - ReceiverPubKey: "", - BountyId: 0, - } - db.AddPaymentHistory(budgetHistory) -} - -func (db database) AddPaymentHistory(payment PaymentHistory) PaymentHistory { - db.db.Create(&payment) - - // get organization budget and subtract payment from total budget - organizationBudget := db.GetOrganizationBudget(payment.OrgUuid) - totalBudget := organizationBudget.TotalBudget - - // deduct amount if it's a bounty payment - if payment.PaymentType == "payment" { - organizationBudget.TotalBudget = totalBudget - payment.Amount - } - - db.UpdateOrganizationBudget(organizationBudget) - - return payment -} - -func (db database) GetPaymentHistory(org_uuid string, r *http.Request) []PaymentHistory { - payment := []PaymentHistory{} - - offset, limit, _, _, _ := utils.GetPaginationParams(r) - limitQuery := "" - - limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset) - - query := `SELECT * FROM payment_histories WHERE org_uuid = '` + org_uuid + `' AND status = true ORDER BY created DESC` - - db.db.Raw(query + " " + limitQuery).Find(&payment) - return payment -} - func (db database) GetInvoice(payment_request string) InvoiceList { ms := InvoiceList{} db.db.Where("payment_request = ?", payment_request).Find(&ms) return ms } -func (db database) GetOrganizationInvoices(org_uuid string) []InvoiceList { - ms := []InvoiceList{} - db.db.Where("org_uuid = ?", org_uuid).Where("status", false).Find(&ms) - return ms -} - -func (db database) GetOrganizationInvoicesCount(org_uuid string) int64 { - var count int64 - ms := InvoiceList{} - - db.db.Model(&ms).Where("org_uuid = ?", org_uuid).Where("status", false).Count(&count) - return count -} - func (db database) UpdateInvoice(payment_request string) InvoiceList { ms := InvoiceList{} db.db.Model(&InvoiceList{}).Where("payment_request = ?", payment_request).Update("status", true) @@ -1950,47 +1673,3 @@ func (db database) DeleteUserInvoiceData(payment_request string) UserInvoiceData db.db.Where("payment_request = ?", payment_request).Delete(&ms) return ms } - -func (db database) ChangeOrganizationDeleteStatus(org_uuid string, status bool) Organization { - ms := Organization{} - db.db.Model(&ms).Where("uuid", org_uuid).Updates(map[string]interface{}{ - "deleted": status, - }) - return ms -} - -func (db database) UpdateOrganizationForDeletion(uuid string) error { - updates := map[string]interface{}{ - "website": "", - "github": "", - "description": "", - "show": false, - } - - result := db.db.Model(&Organization{}).Where("uuid = ?", uuid).Updates(updates) - if result.Error != nil { - return result.Error - } - - return nil -} - -func (db database) DeleteAllUsersFromOrganization(org string) error { - if org == "" { - return errors.New("no org uuid provided") - } - - // Delete all users associated with the organization - result := db.db.Where("org_uuid = ?", org).Delete(&OrganizationUsers{}) - if result.Error != nil { - return result.Error - } - - // Delete all user roles associated with the organization - result = db.db.Where("org_uuid = ?", org).Delete(&UserRoles{}) - if result.Error != nil { - return result.Error - } - - return nil -} diff --git a/db/interface.go b/db/interface.go index fc0e08d3b..4bd082473 100644 --- a/db/interface.go +++ b/db/interface.go @@ -31,15 +31,15 @@ type Database interface { GetListedPosts(r *http.Request) ([]PeopleExtra, error) GetUserBountiesCount(personKey string, tabType string) int64 GetBountiesCount(r *http.Request) int64 - GetOrganizationBounties(r *http.Request, org_uuid string) []Bounty - GetOrganizationBountiesCount(r *http.Request, org_uuid string) int64 + GetWorkspaceBounties(r *http.Request, org_uuid string) []Bounty + GetWorkspaceBountiesCount(r *http.Request, org_uuid string) int64 GetAssignedBounties(r *http.Request) ([]Bounty, error) GetCreatedBounties(r *http.Request) ([]Bounty, error) GetBountyById(id string) ([]Bounty, error) GetNextBountyByCreated(r *http.Request) (uint, error) GetPreviousBountyByCreated(r *http.Request) (uint, error) - GetNextOrganizationBountyByCreated(r *http.Request) (uint, error) - GetPreviousOrganizationBountyByCreated(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) AddBounty(b Bounty) (Bounty, error) @@ -83,43 +83,43 @@ type Database interface { GetLnUser(lnKey string) int64 CreateLnUser(lnKey string) (Person, error) GetBountiesLeaderboard() []LeaderData - GetOrganizations(r *http.Request) []Organization - GetOrganizationsCount() int64 - GetOrganizationByUuid(uuid string) Organization - GetOrganizationByName(name string) Organization - CreateOrEditOrganization(m Organization) (Organization, error) - GetOrganizationUsers(uuid string) ([]OrganizationUsersData, error) - GetOrganizationUsersCount(uuid string) int64 - GetOrganizationBountyCount(uuid string) int64 - GetOrganizationUser(pubkey string, org_uuid string) OrganizationUsers - CreateOrganizationUser(orgUser OrganizationUsers) OrganizationUsers - DeleteOrganizationUser(orgUser OrganizationUsersData, org string) OrganizationUsersData + GetWorkspaces(r *http.Request) []Organization + GetWorkspacesCount() int64 + GetWorkspaceByUuid(uuid string) Organization + GetWorkspaceByName(name string) Organization + CreateOrEditWorkspace(m Organization) (Organization, error) + GetWorkspaceUsers(uuid string) ([]OrganizationUsersData, error) + GetWorkspaceUsersCount(uuid string) int64 + GetWorkspaceBountyCount(uuid string) int64 + GetWorkspaceUser(pubkey string, org_uuid string) OrganizationUsers + CreateWorkspaceUser(orgUser OrganizationUsers) OrganizationUsers + DeleteWorkspaceUser(orgUser OrganizationUsersData, org string) OrganizationUsersData GetBountyRoles() []BountyRoles CreateUserRoles(roles []UserRoles, uuid string, pubkey string) []UserRoles - GetUserCreatedOrganizations(pubkey string) []Organization - GetUserAssignedOrganizations(pubkey string) []OrganizationUsers + GetUserCreatedWorkspaces(pubkey string) []Organization + GetUserAssignedWorkspaces(pubkey string) []OrganizationUsers AddBudgetHistory(budget BudgetHistory) BudgetHistory - CreateOrganizationBudget(budget BountyBudget) BountyBudget - UpdateOrganizationBudget(budget BountyBudget) BountyBudget + CreateWorkspaceBudget(budget BountyBudget) BountyBudget + UpdateWorkspaceBudget(budget BountyBudget) BountyBudget GetPaymentHistoryByCreated(created *time.Time, org_uuid string) PaymentHistory - GetOrganizationBudget(org_uuid string) BountyBudget - GetOrganizationStatusBudget(org_uuid string) StatusBudget - GetOrganizationBudgetHistory(org_uuid string) []BudgetHistoryData + GetWorkspaceBudget(org_uuid string) BountyBudget + GetWorkspaceStatusBudget(org_uuid string) StatusBudget + GetWorkspaceBudgetHistory(org_uuid string) []BudgetHistoryData AddAndUpdateBudget(invoice InvoiceList) PaymentHistory WithdrawBudget(sender_pubkey string, org_uuid string, amount uint) AddPaymentHistory(payment PaymentHistory) PaymentHistory GetPaymentHistory(org_uuid string, r *http.Request) []PaymentHistory GetInvoice(payment_request string) InvoiceList - GetOrganizationInvoices(org_uuid string) []InvoiceList - GetOrganizationInvoicesCount(org_uuid string) int64 + GetWorkspaceInvoices(org_uuid string) []InvoiceList + GetWorkspaceInvoicesCount(org_uuid string) int64 UpdateInvoice(payment_request string) InvoiceList AddInvoice(invoice InvoiceList) InvoiceList AddUserInvoiceData(userData UserInvoiceData) UserInvoiceData GetUserInvoiceData(payment_request string) UserInvoiceData DeleteUserInvoiceData(payment_request string) UserInvoiceData - ChangeOrganizationDeleteStatus(org_uuid string, status bool) Organization - UpdateOrganizationForDeletion(uuid string) error - DeleteAllUsersFromOrganization(uuid string) error + ChangeWorkspaceDeleteStatus(org_uuid string, status bool) Organization + UpdateWorkspaceForDeletion(uuid string) error + DeleteAllUsersFromWorkspace(uuid string) error GetFilterStatusCount() FilterStattuCount UserHasManageBountyRoles(pubKeyFromAuth string, uuid string) bool BountiesPaidPercentage(r PaymentDateRange) uint diff --git a/db/metrics.go b/db/metrics.go index cf63dcebe..1a1f0e870 100644 --- a/db/metrics.go +++ b/db/metrics.go @@ -17,7 +17,7 @@ func (db database) TotalPeopleByDateRange(r PaymentDateRange) int64 { return count } -func (db database) TotalOrganizationsByDateRange(r PaymentDateRange) int64 { +func (db database) TotalWorkspacesByDateRange(r PaymentDateRange) int64 { var count int64 db.db.Model(&Organization{}).Where("created >= ?", r.StartDate).Where("created <= ?", r.EndDate).Count(&count) return count diff --git a/db/structs.go b/db/structs.go index c3a6794de..934f1ae15 100644 --- a/db/structs.go +++ b/db/structs.go @@ -400,32 +400,32 @@ type BountyData struct { BountyUpdated *time.Time `json:"bounty_updated"` BountyDescription string `json:"bounty_description"` Person - AssigneeAlias string `json:"assignee_alias"` - AssigneeId uint `json:"assignee_id"` - AssigneeImg string `json:"assignee_img"` - AssigneeCreated *time.Time `json:"assignee_created"` - AssigneeUpdated *time.Time `json:"assignee_updated"` - AssigneeDescription string `json:"assignee_description"` - AssigneeRouteHint string `json:"assignee_route_hint"` - BountyOwnerId uint `json:"bounty_owner_id"` - OwnerUuid string `json:"owner_uuid"` - OwnerKey string `json:"owner_key"` - OwnerAlias string `json:"owner_alias"` - OwnerUniqueName string `json:"owner_unique_name"` - OwnerDescription string `json:"owner_description"` - OwnerTags pq.StringArray `gorm:"type:text[]" json:"owner_tags" null` - OwnerImg string `json:"owner_img"` - OwnerCreated *time.Time `json:"owner_created"` - OwnerUpdated *time.Time `json:"owner_updated"` - OwnerLastLogin int64 `json:"owner_last_login"` - OwnerRouteHint string `json:"owner_route_hint"` - OwnerContactKey string `json:"owner_contact_key"` - OwnerPriceToMeet int64 `json:"owner_price_to_meet"` - OwnerTwitterConfirmed bool `json:"owner_twitter_confirmed"` - OrganizationName string `json:"organization_name"` - OrganizationImg string `json:"organization_img"` - OrganizationUuid string `json:"organization_uuid"` - OrganizationDescription string `json:"description"` + AssigneeAlias string `json:"assignee_alias"` + AssigneeId uint `json:"assignee_id"` + AssigneeImg string `json:"assignee_img"` + AssigneeCreated *time.Time `json:"assignee_created"` + AssigneeUpdated *time.Time `json:"assignee_updated"` + AssigneeDescription string `json:"assignee_description"` + AssigneeRouteHint string `json:"assignee_route_hint"` + BountyOwnerId uint `json:"bounty_owner_id"` + OwnerUuid string `json:"owner_uuid"` + OwnerKey string `json:"owner_key"` + OwnerAlias string `json:"owner_alias"` + OwnerUniqueName string `json:"owner_unique_name"` + OwnerDescription string `json:"owner_description"` + OwnerTags pq.StringArray `gorm:"type:text[]" json:"owner_tags" null` + OwnerImg string `json:"owner_img"` + OwnerCreated *time.Time `json:"owner_created"` + OwnerUpdated *time.Time `json:"owner_updated"` + OwnerLastLogin int64 `json:"owner_last_login"` + OwnerRouteHint string `json:"owner_route_hint"` + OwnerContactKey string `json:"owner_contact_key"` + OwnerPriceToMeet int64 `json:"owner_price_to_meet"` + OwnerTwitterConfirmed bool `json:"owner_twitter_confirmed"` + OrganizationName string `json:"organization_name"` + OrganizationImg string `json:"organization_img"` + WorkspaceUuid string `json:"organization_uuid"` + WorkspaceDescription string `json:"description"` } type BountyResponse struct { diff --git a/db/workspaces.go b/db/workspaces.go new file mode 100644 index 000000000..29ea28ee4 --- /dev/null +++ b/db/workspaces.go @@ -0,0 +1,331 @@ +package db + +import ( + "errors" + "fmt" + "net/http" + "time" + + "github.com/stakwork/sphinx-tribes/utils" +) + +func (db database) GetWorkspaces(r *http.Request) []Organization { + ms := []Organization{} + offset, limit, sortBy, direction, search := utils.GetPaginationParams(r) + + // return if like owner_alias, unique_name, or equals pubkey + db.db.Offset(offset).Limit(limit).Order(sortBy+" "+direction+" ").Where("LOWER(name) LIKE ?", "%"+search+"%").Where("deleted != ?", false).Find(&ms) + return ms +} + +func (db database) GetWorkspacesCount() int64 { + var count int64 + db.db.Model(&Organization{}).Count(&count) + return count +} + +func (db database) GetWorkspaceByUuid(uuid string) Organization { + ms := Organization{} + + db.db.Model(&Organization{}).Where("uuid = ?", uuid).Find(&ms) + + return ms +} + +func (db database) GetWorkspaceByName(name string) Organization { + ms := Organization{} + + db.db.Model(&Organization{}).Where("name = ?", name).Find(&ms) + + return ms +} + +func (db database) CreateOrEditWorkspace(m Organization) (Organization, error) { + if m.OwnerPubKey == "" { + return Organization{}, errors.New("no pub key") + } + + if db.db.Model(&m).Where("uuid = ?", m.Uuid).Updates(&m).RowsAffected == 0 { + db.db.Create(&m) + } + + return m, nil +} + +func (db database) GetWorkspaceUsers(uuid string) ([]OrganizationUsersData, error) { + ms := []OrganizationUsersData{} + + err := db.db.Raw(`SELECT org.org_uuid, org.created as user_created, person.* FROM public.organization_users AS org LEFT OUTER JOIN public.people AS person ON org.owner_pub_key = person.owner_pub_key WHERE org.org_uuid = '` + uuid + `' ORDER BY org.created DESC`).Find(&ms).Error + + return ms, err +} + +func (db database) GetWorkspaceUsersCount(uuid string) int64 { + var count int64 + db.db.Model(&OrganizationUsers{}).Where("org_uuid = ?", uuid).Count(&count) + return count +} + +func (db database) GetWorkspaceBountyCount(uuid string) int64 { + var count int64 + db.db.Model(&Bounty{}).Where("org_uuid = ?", uuid).Count(&count) + return count +} + +func (db database) GetWorkspaceUser(pubkey string, org_uuid string) OrganizationUsers { + ms := OrganizationUsers{} + db.db.Where("org_uuid = ?", org_uuid).Where("owner_pub_key = ?", pubkey).Find(&ms) + return ms +} + +func (db database) CreateWorkspaceUser(orgUser OrganizationUsers) OrganizationUsers { + db.db.Create(&orgUser) + + return orgUser +} + +func (db database) DeleteWorkspaceUser(orgUser OrganizationUsersData, org string) OrganizationUsersData { + db.db.Where("owner_pub_key = ?", orgUser.OwnerPubKey).Where("org_uuid = ?", org).Delete(&OrganizationUsers{}) + db.db.Where("owner_pub_key = ?", orgUser.OwnerPubKey).Where("org_uuid = ?", org).Delete(&UserRoles{}) + return orgUser +} + +func (db database) GetBountyRoles() []BountyRoles { + ms := []BountyRoles{} + db.db.Find(&ms) + return ms +} + +func (db database) CreateUserRoles(roles []UserRoles, uuid string, pubkey string) []UserRoles { + // delete roles and create new ones + db.db.Where("org_uuid = ?", uuid).Where("owner_pub_key = ?", pubkey).Delete(&UserRoles{}) + db.db.Create(&roles) + + return roles +} + +func (db database) GetUserRoles(uuid string, pubkey string) []UserRoles { + ms := []UserRoles{} + db.db.Where("org_uuid = ?", uuid).Where("owner_pub_key = ?", pubkey).Find(&ms) + return ms +} + +func (db database) GetUserCreatedWorkspaces(pubkey string) []Organization { + ms := []Organization{} + db.db.Where("owner_pub_key = ?", pubkey).Where("deleted != ?", true).Find(&ms) + return ms +} + +func (db database) GetUserAssignedWorkspaces(pubkey string) []OrganizationUsers { + ms := []OrganizationUsers{} + db.db.Where("owner_pub_key = ?", pubkey).Find(&ms) + return ms +} + +func (db database) AddBudgetHistory(budget BudgetHistory) BudgetHistory { + db.db.Create(&budget) + return budget +} + +func (db database) CreateWorkspaceBudget(budget BountyBudget) BountyBudget { + db.db.Create(&budget) + return budget +} + +func (db database) UpdateWorkspaceBudget(budget BountyBudget) BountyBudget { + db.db.Model(&BountyBudget{}).Where("org_uuid = ?", budget.OrgUuid).Updates(map[string]interface{}{ + "total_budget": budget.TotalBudget, + }) + return budget +} + +func (db database) GetPaymentHistoryByCreated(created *time.Time, org_uuid string) PaymentHistory { + ms := PaymentHistory{} + db.db.Where("created = ?", created).Where("org_uuid = ? ", org_uuid).Find(&ms) + return ms +} + +func (db database) GetWorkspaceBudget(org_uuid string) BountyBudget { + ms := BountyBudget{} + db.db.Where("org_uuid = ?", org_uuid).Find(&ms) + + return ms +} + +func (db database) GetWorkspaceStatusBudget(org_uuid string) StatusBudget { + + orgBudget := db.GetWorkspaceBudget(org_uuid) + + var openBudget uint + db.db.Model(&Bounty{}).Where("assignee = '' ").Where("paid != true").Select("SUM(price)").Row().Scan(&openBudget) + + var assignedBudget uint + db.db.Model(&Bounty{}).Where("assignee != '' ").Where("paid != true").Select("SUM(price)").Row().Scan(&assignedBudget) + + var completedBudget uint + db.db.Model(&Bounty{}).Where("completed = true ").Where("paid != true").Select("SUM(price)").Row().Scan(&completedBudget) + + statusBudget := StatusBudget{ + OrgUuid: org_uuid, + CurrentBudget: orgBudget.TotalBudget, + OpenBudget: openBudget, + AssignedBudget: assignedBudget, + CompletedBudget: completedBudget, + } + + return statusBudget +} + +func (db database) GetWorkspaceBudgetHistory(org_uuid string) []BudgetHistoryData { + budgetHistory := []BudgetHistoryData{} + + db.db.Raw(`SELECT budget.id, budget.org_uuid, budget.amount, budget.created, budget.updated, budget.payment_type, budget.status, budget.sender_pub_key, sender.unique_name AS sender_name FROM public.budget_histories AS budget LEFT OUTER JOIN public.people AS sender ON budget.sender_pub_key = sender.owner_pub_key WHERE budget.org_uuid = '` + org_uuid + `' ORDER BY budget.created DESC`).Find(&budgetHistory) + return budgetHistory +} + +func (db database) AddAndUpdateBudget(invoice InvoiceList) PaymentHistory { + created := invoice.Created + org_uuid := invoice.OrgUuid + + paymentHistory := db.GetPaymentHistoryByCreated(created, org_uuid) + + if paymentHistory.OrgUuid != "" && paymentHistory.Amount != 0 { + paymentHistory.Status = true + db.db.Where("created = ?", created).Where("org_uuid = ? ", org_uuid).Updates(paymentHistory) + + // get organization budget and add payment to total budget + organizationBudget := db.GetWorkspaceBudget(org_uuid) + + if organizationBudget.OrgUuid == "" { + now := time.Now() + orgBudget := BountyBudget{ + OrgUuid: org_uuid, + TotalBudget: paymentHistory.Amount, + Created: &now, + Updated: &now, + } + db.CreateWorkspaceBudget(orgBudget) + } else { + totalBudget := organizationBudget.TotalBudget + organizationBudget.TotalBudget = totalBudget + paymentHistory.Amount + db.UpdateWorkspaceBudget(organizationBudget) + } + } + + return paymentHistory +} + +func (db database) WithdrawBudget(sender_pubkey string, org_uuid string, amount uint) { + // get organization budget and add payment to total budget + organizationBudget := db.GetWorkspaceBudget(org_uuid) + totalBudget := organizationBudget.TotalBudget + + newBudget := totalBudget - amount + db.db.Model(&BountyBudget{}).Where("org_uuid = ?", org_uuid).Updates(map[string]interface{}{ + "total_budget": newBudget, + }) + + now := time.Now() + + budgetHistory := PaymentHistory{ + OrgUuid: org_uuid, + Amount: amount, + Status: true, + PaymentType: "withdraw", + Created: &now, + Updated: &now, + SenderPubKey: sender_pubkey, + ReceiverPubKey: "", + BountyId: 0, + } + db.AddPaymentHistory(budgetHistory) +} + +func (db database) AddPaymentHistory(payment PaymentHistory) PaymentHistory { + db.db.Create(&payment) + + // get organization budget and subtract payment from total budget + organizationBudget := db.GetWorkspaceBudget(payment.OrgUuid) + totalBudget := organizationBudget.TotalBudget + + // deduct amount if it's a bounty payment + if payment.PaymentType == "payment" { + organizationBudget.TotalBudget = totalBudget - payment.Amount + } + + db.UpdateWorkspaceBudget(organizationBudget) + + return payment +} + +func (db database) GetPaymentHistory(org_uuid string, r *http.Request) []PaymentHistory { + payment := []PaymentHistory{} + + offset, limit, _, _, _ := utils.GetPaginationParams(r) + limitQuery := "" + + limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset) + + query := `SELECT * FROM payment_histories WHERE org_uuid = '` + org_uuid + `' AND status = true ORDER BY created DESC` + + db.db.Raw(query + " " + limitQuery).Find(&payment) + return payment +} + +func (db database) GetWorkspaceInvoices(org_uuid string) []InvoiceList { + ms := []InvoiceList{} + db.db.Where("org_uuid = ?", org_uuid).Where("status", false).Find(&ms) + return ms +} + +func (db database) GetWorkspaceInvoicesCount(org_uuid string) int64 { + var count int64 + ms := InvoiceList{} + + db.db.Model(&ms).Where("org_uuid = ?", org_uuid).Where("status", false).Count(&count) + return count +} + +func (db database) ChangeWorkspaceDeleteStatus(org_uuid string, status bool) Organization { + ms := Organization{} + db.db.Model(&ms).Where("uuid", org_uuid).Updates(map[string]interface{}{ + "deleted": status, + }) + return ms +} + +func (db database) UpdateWorkspaceForDeletion(uuid string) error { + updates := map[string]interface{}{ + "website": "", + "github": "", + "description": "", + "show": false, + } + + result := db.db.Model(&Organization{}).Where("uuid = ?", uuid).Updates(updates) + if result.Error != nil { + return result.Error + } + + return nil +} + +func (db database) DeleteAllUsersFromWorkspace(org string) error { + if org == "" { + return errors.New("no org uuid provided") + } + + // Delete all users associated with the organization + result := db.db.Where("org_uuid = ?", org).Delete(&OrganizationUsers{}) + if result.Error != nil { + return result.Error + } + + // Delete all user roles associated with the organization + result = db.db.Where("org_uuid = ?", org).Delete(&UserRoles{}) + if result.Error != nil { + return result.Error + } + + return nil +} diff --git a/handlers/bounty.go b/handlers/bounty.go index 7ef6bd60d..d3f9e58fa 100644 --- a/handlers/bounty.go +++ b/handlers/bounty.go @@ -86,8 +86,8 @@ func (h *bountyHandler) GetPreviousBountyByCreated(w http.ResponseWriter, r *htt } } -func (h *bountyHandler) GetOrganizationNextBountyByCreated(w http.ResponseWriter, r *http.Request) { - bounties, err := h.db.GetNextOrganizationBountyByCreated(r) +func (h *bountyHandler) GetWorkspaceNextBountyByCreated(w http.ResponseWriter, r *http.Request) { + bounties, err := h.db.GetNextWorkspaceBountyByCreated(r) if err != nil { w.WriteHeader(http.StatusBadRequest) fmt.Println("Error", err) @@ -97,8 +97,8 @@ func (h *bountyHandler) GetOrganizationNextBountyByCreated(w http.ResponseWriter } } -func (h *bountyHandler) GetOrganizationPreviousBountyByCreated(w http.ResponseWriter, r *http.Request) { - bounties, err := h.db.GetPreviousOrganizationBountyByCreated(r) +func (h *bountyHandler) GetWorkspacePreviousBountyByCreated(w http.ResponseWriter, r *http.Request) { + bounties, err := h.db.GetPreviousWorkspaceBountyByCreated(r) if err != nil { w.WriteHeader(http.StatusBadRequest) fmt.Println("Error", err) @@ -359,7 +359,7 @@ func (h *bountyHandler) GenerateBountyResponse(bounties []db.Bounty) []db.Bounty owner := h.db.GetPersonByPubkey(bounty.OwnerID) assignee := h.db.GetPersonByPubkey(bounty.Assignee) - organization := h.db.GetOrganizationByUuid(bounty.OrgUuid) + organization := h.db.GetWorkspaceByUuid(bounty.OrgUuid) b := db.BountyResponse{ Bounty: db.Bounty{ @@ -483,7 +483,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request // check if the organization bounty balance // is greater than the amount - orgBudget := h.db.GetOrganizationBudget(bounty.OrgUuid) + orgBudget := h.db.GetWorkspaceBudget(bounty.OrgUuid) if orgBudget.TotalBudget < amount { w.WriteHeader(http.StatusForbidden) json.NewEncoder(w).Encode("organization budget is not enough to pay the amount") @@ -523,7 +523,7 @@ func (h *bountyHandler) MakeBountyPayment(w http.ResponseWriter, r *http.Request msg := make(map[string]interface{}) // payment is successful add to payment history - // and reduce organizations budget + // and reduce workspaces budget if res.StatusCode == 200 { // Unmarshal result keysendRes := db.KeysendSuccess{} @@ -607,10 +607,10 @@ func (h *bountyHandler) BountyBudgetWithdraw(w http.ResponseWriter, r *http.Requ if err == nil && amount > 0 { // check if the organization bounty balance // is greater than the amount - orgBudget := h.db.GetOrganizationBudget(request.OrgUuid) + orgBudget := h.db.GetWorkspaceBudget(request.OrgUuid) if amount > orgBudget.TotalBudget { w.WriteHeader(http.StatusForbidden) - errMsg := formatPayError("Organization budget is not enough to withdraw the amount") + errMsg := formatPayError("Workspace budget is not enough to withdraw the amount") json.NewEncoder(w).Encode(errMsg) return } diff --git a/handlers/bounty_test.go b/handlers/bounty_test.go index 4eed4179e..21432500a 100644 --- a/handlers/bounty_test.go +++ b/handlers/bounty_test.go @@ -540,7 +540,7 @@ func TestGetBountyByCreated(t *testing.T) { mockDb.On("GetBountyDataByCreated", createdStr).Return([]db.Bounty{bounty}, nil).Once() mockDb.On("GetPersonByPubkey", "owner-1").Return(db.Person{}).Once() mockDb.On("GetPersonByPubkey", "user1").Return(db.Person{}).Once() - mockDb.On("GetOrganizationByUuid", "org-1").Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByUuid", "org-1").Return(db.Organization{}).Once() handler.ServeHTTP(rr, req) var returnedBounty []db.BountyResponse @@ -598,7 +598,7 @@ func TestGetPersonAssignedBounties(t *testing.T) { mockDb.On("GetAssignedBounties", req).Return([]db.Bounty{bounty}, nil).Once() mockDb.On("GetPersonByPubkey", "owner-1").Return(db.Person{}, nil).Once() mockDb.On("GetPersonByPubkey", "user1").Return(db.Person{}, nil).Once() - mockDb.On("GetOrganizationByUuid", "org-1").Return(db.Organization{}, nil).Once() + mockDb.On("GetWorkspaceByUuid", "org-1").Return(db.Organization{}, nil).Once() handler.ServeHTTP(rr, req) var returnedBounty []db.BountyResponse @@ -650,7 +650,7 @@ func TestGetPersonCreatedBounties(t *testing.T) { mockDb.On("GetCreatedBounties", mock.Anything).Return(expectedBounties, nil).Once() mockDb.On("GetPersonByPubkey", mock.Anything).Return(db.Person{}, nil) - mockDb.On("GetOrganizationByUuid", mock.Anything).Return(db.Organization{}, nil) + mockDb.On("GetWorkspaceByUuid", mock.Anything).Return(db.Organization{}, nil) rr := httptest.NewRecorder() req, err := http.NewRequest("GET", "/people/wanteds/created/uuid", nil) req = req.WithContext(ctx) @@ -742,7 +742,7 @@ func TestGetPersonCreatedBounties(t *testing.T) { mockDb.On("GetCreatedBounties", mock.Anything).Return(expectedBounties, nil).Once() mockDb.On("GetPersonByPubkey", mock.Anything).Return(db.Person{}, nil) - mockDb.On("GetOrganizationByUuid", mock.Anything).Return(db.Organization{}, nil) + mockDb.On("GetWorkspaceByUuid", mock.Anything).Return(db.Organization{}, nil) rr := httptest.NewRecorder() req, err := http.NewRequest("GET", "/people/wanteds/created/uuid?Open=true&Assigned=true&Paid=true&offset=0&limit=2", nil) @@ -810,38 +810,38 @@ func TestGetPreviousBountyByCreated(t *testing.T) { }) } -func TestGetOrganizationNextBountyByCreated(t *testing.T) { +func TestGetWorkspaceNextBountyByCreated(t *testing.T) { ctx := context.Background() mockDb := dbMocks.NewDatabase(t) mockHttpClient := mocks.NewHttpClient(t) bHandler := NewBountyHandler(mockHttpClient, mockDb) t.Run("Should test that the next bounty on the organization bounties homepage can be gotten by its created value and the selected filters", func(t *testing.T) { - mockDb.On("GetNextOrganizationBountyByCreated", mock.AnythingOfType("*http.Request")).Return(uint(1), nil).Once() + mockDb.On("GetNextWorkspaceBountyByCreated", mock.AnythingOfType("*http.Request")).Return(uint(1), nil).Once() rr := httptest.NewRecorder() req, _ := http.NewRequest("GET", "/org/next/org-uuid/123456789", nil) - bHandler.GetOrganizationNextBountyByCreated(rr, req.WithContext(ctx)) + bHandler.GetWorkspaceNextBountyByCreated(rr, req.WithContext(ctx)) assert.Equal(t, http.StatusOK, rr.Code) mockDb.AssertExpectations(t) }) } -func TestGetOrganizationPreviousBountyByCreated(t *testing.T) { +func TestGetWorkspacePreviousBountyByCreated(t *testing.T) { ctx := context.Background() mockDb := dbMocks.NewDatabase(t) mockHttpClient := mocks.NewHttpClient(t) bHandler := NewBountyHandler(mockHttpClient, mockDb) t.Run("Should test that the previous bounty on the organization bounties homepage can be gotten by its created value and the selected filters", func(t *testing.T) { - mockDb.On("GetPreviousOrganizationBountyByCreated", mock.AnythingOfType("*http.Request")).Return(uint(1), nil).Once() + mockDb.On("GetPreviousWorkspaceBountyByCreated", mock.AnythingOfType("*http.Request")).Return(uint(1), nil).Once() rr := httptest.NewRecorder() req, _ := http.NewRequest("GET", "/org/previous/org-uuid/123456789", nil) - bHandler.GetOrganizationPreviousBountyByCreated(rr, req.WithContext(ctx)) + bHandler.GetWorkspacePreviousBountyByCreated(rr, req.WithContext(ctx)) assert.Equal(t, http.StatusOK, rr.Code) @@ -899,7 +899,7 @@ func TestGetBountyById(t *testing.T) { mockDb.On("GetBountyById", mock.Anything).Return([]db.Bounty{bounty}, nil).Once() mockDb.On("GetPersonByPubkey", "owner123").Return(db.Person{}).Once() mockDb.On("GetPersonByPubkey", "user1").Return(db.Person{}).Once() - mockDb.On("GetOrganizationByUuid", "org-789").Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByUuid", "org-789").Return(db.Organization{}).Once() handler.ServeHTTP(rr, req) @@ -969,7 +969,7 @@ func GetPersonAssigned(t *testing.T) { mockDb.On("GetAssignedBounties", mock.Anything).Return(expectedBounties, nil).Once() mockDb.On("GetPersonByPubkey", mock.Anything).Return(db.Person{}, nil) - mockDb.On("GetOrganizationByUuid", mock.Anything).Return(db.Organization{}, nil) + mockDb.On("GetWorkspaceByUuid", mock.Anything).Return(db.Organization{}, nil) rr := httptest.NewRecorder() req, err := http.NewRequest("GET", "/wanteds/assigned/uuid?Assigned=true&Paid=true&offset=0&limit=4", nil) req = req.WithContext(ctx) @@ -1101,7 +1101,7 @@ func TestGetAllBounties(t *testing.T) { mockDb.On("GetAllBounties", req).Return(bounties) mockDb.On("GetPersonByPubkey", mock.Anything).Return(db.Person{}, nil) - mockDb.On("GetOrganizationByUuid", mock.Anything).Return(db.Organization{}, nil) + mockDb.On("GetWorkspaceByUuid", mock.Anything).Return(db.Organization{}, nil) handler.ServeHTTP(rr, req) var returnedBounty []db.BountyResponse @@ -1287,7 +1287,7 @@ func TestMakeBountyPayment(t *testing.T) { Assignee: "assignee-1", Paid: false, }, nil) - mockDb.On("GetOrganizationBudget", "org-1").Return(db.BountyBudget{ + mockDb.On("GetWorkspaceBudget", "org-1").Return(db.BountyBudget{ TotalBudget: 500, }, nil) @@ -1323,7 +1323,7 @@ func TestMakeBountyPayment(t *testing.T) { } mockDb.On("GetBounty", bountyID).Return(bounty, nil) - mockDb.On("GetOrganizationBudget", bounty.OrgUuid).Return(db.BountyBudget{TotalBudget: 2000}, nil) + mockDb.On("GetWorkspaceBudget", bounty.OrgUuid).Return(db.BountyBudget{TotalBudget: 2000}, nil) mockDb.On("GetPersonByPubkey", bounty.Assignee).Return(db.Person{OwnerPubKey: "assignee-1", OwnerRouteHint: "OwnerRouteHint"}, nil) mockDb.On("AddPaymentHistory", mock.AnythingOfType("db.PaymentHistory")).Return(db.PaymentHistory{ID: 1}) mockDb.On("UpdateBounty", mock.AnythingOfType("db.Bounty")).Run(func(args mock.Arguments) { @@ -1372,7 +1372,7 @@ func TestMakeBountyPayment(t *testing.T) { bHandler2.userHasAccess = mockUserHasAccessTrue mockDb2.On("GetBounty", bountyID).Return(bounty, nil) - mockDb2.On("GetOrganizationBudget", bounty.OrgUuid).Return(db.BountyBudget{TotalBudget: 2000}, nil) + mockDb2.On("GetWorkspaceBudget", bounty.OrgUuid).Return(db.BountyBudget{TotalBudget: 2000}, nil) mockDb2.On("GetPersonByPubkey", bounty.Assignee).Return(db.Person{OwnerPubKey: "assignee-1", OwnerRouteHint: "OwnerRouteHint"}, nil) expectedUrl := fmt.Sprintf("%s/payment", config.RelayUrl) @@ -1472,7 +1472,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { bHandler := NewBountyHandler(mockHttpClient, mockDb) bHandler.userHasAccess = mockUserHasAccessTrue - mockDb.On("GetOrganizationBudget", "org-1").Return(db.BountyBudget{ + mockDb.On("GetWorkspaceBudget", "org-1").Return(db.BountyBudget{ TotalBudget: 500, }, nil) invoice := "lnbc15u1p3xnhl2pp5jptserfk3zk4qy42tlucycrfwxhydvlemu9pqr93tuzlv9cc7g3sdqsvfhkcap3xyhx7un8cqzpgxqzjcsp5f8c52y2stc300gl6s4xswtjpc37hrnnr3c9wvtgjfuvqmpm35evq9qyyssqy4lgd8tj637qcjp05rdpxxykjenthxftej7a2zzmwrmrl70fyj9hvj0rewhzj7jfyuwkwcg9g2jpwtk3wkjtwnkdks84hsnu8xps5vsq4gj5hs" @@ -1492,7 +1492,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { bHandler.BountyBudgetWithdraw(rr, req) assert.Equal(t, http.StatusForbidden, rr.Code, "Expected 403 Forbidden when the payment exceeds the organization's budget") - assert.Contains(t, rr.Body.String(), "Organization budget is not enough to withdraw the amount", "Expected specific error message") + assert.Contains(t, rr.Body.String(), "Workspace budget is not enough to withdraw the amount", "Expected specific error message") }) t.Run("budget invoices get paid if amount is lesser than organization's budget", func(t *testing.T) { @@ -1504,7 +1504,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { paymentAmount := uint(1500) - mockDb.On("GetOrganizationBudget", "org-1").Return(db.BountyBudget{ + mockDb.On("GetWorkspaceBudget", "org-1").Return(db.BountyBudget{ TotalBudget: 5000, }, nil) mockDb.On("WithdrawBudget", "valid-key", "org-1", paymentAmount).Return(nil) @@ -1541,7 +1541,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { bHandler := NewBountyHandler(mockHttpClient, mockDb) bHandler.userHasAccess = mockUserHasAccessTrue - mockDb.On("GetOrganizationBudget", "org-1").Return(db.BountyBudget{ + mockDb.On("GetWorkspaceBudget", "org-1").Return(db.BountyBudget{ TotalBudget: 5000, }, nil) mockHttpClient.On("Do", mock.AnythingOfType("*http.Request")).Return(&http.Response{ @@ -1571,7 +1571,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { mockHttpClient.AssertCalled(t, "Do", mock.AnythingOfType("*http.Request")) }) - t.Run("Should test that an Organization's Budget Total Amount is accurate after three (3) successful 'Budget Withdrawal Requests'", func(t *testing.T) { + t.Run("Should test that an Workspace's Budget Total Amount is accurate after three (3) successful 'Budget Withdrawal Requests'", func(t *testing.T) { ctxs := context.WithValue(context.Background(), auth.ContextKey, "valid-key") mockDb := dbMocks.NewDatabase(t) mockHttpClient := mocks.NewHttpClient(t) @@ -1590,7 +1590,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { mockHttpClient.ExpectedCalls = nil mockHttpClient.Calls = nil - mockDb.On("GetOrganizationBudget", "org-1").Return(db.BountyBudget{ + mockDb.On("GetWorkspaceBudget", "org-1").Return(db.BountyBudget{ TotalBudget: expectedFinalBudget, }, nil) mockDb.On("WithdrawBudget", "valid-key", "org-1", paymentAmount).Return(nil) @@ -1614,7 +1614,7 @@ func TestBountyBudgetWithdraw(t *testing.T) { err := json.Unmarshal(rr.Body.Bytes(), &response) assert.NoError(t, err) assert.True(t, response.Success, "Expected invoice payment to succeed") - finalBudget := mockDb.GetOrganizationBudget("org-1") + finalBudget := mockDb.GetWorkspaceBudget("org-1") assert.Equal(t, expectedFinalBudget, finalBudget.TotalBudget, "The organization's final budget should reflect the deductions from the successful withdrawals") } diff --git a/handlers/invoiceCron.go b/handlers/invoiceCron.go index f1f578d8b..b1914150a 100644 --- a/handlers/invoiceCron.go +++ b/handlers/invoiceCron.go @@ -202,7 +202,7 @@ func InitInvoiceCron() { err = json.Unmarshal(body, &invoiceRes) if err != nil { - log.Printf("Reading Organization Invoice body failed: %s", err) + log.Printf("Reading Workspace Invoice body failed: %s", err) return } diff --git a/handlers/metrics.go b/handlers/metrics.go index 6faeb7521..2a0140cb5 100644 --- a/handlers/metrics.go +++ b/handlers/metrics.go @@ -57,7 +57,7 @@ func PaymentMetrics(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(sumAmount) } -func OrganizationtMetrics(w http.ResponseWriter, r *http.Request) { +func WorkspacetMetrics(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) @@ -78,7 +78,7 @@ func OrganizationtMetrics(w http.ResponseWriter, r *http.Request) { return } - sumAmount := db.DB.TotalOrganizationsByDateRange(request) + sumAmount := db.DB.TotalWorkspacesByDateRange(request) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(sumAmount) @@ -105,7 +105,7 @@ func PeopleMetrics(w http.ResponseWriter, r *http.Request) { return } - sumAmount := db.DB.TotalOrganizationsByDateRange(request) + sumAmount := db.DB.TotalWorkspacesByDateRange(request) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(sumAmount) @@ -305,29 +305,29 @@ func (mh *metricHandler) GetMetricsBountiesData(metricBounties []db.Bounty) []db for _, bounty := range metricBounties { bountyOwner := mh.db.GetPersonByPubkey(bounty.OwnerID) bountyAssignee := mh.db.GetPersonByPubkey(bounty.Assignee) - organization := mh.db.GetOrganizationByUuid(bounty.OrgUuid) + organization := mh.db.GetWorkspaceByUuid(bounty.OrgUuid) bountyData := db.BountyData{ - Bounty: bounty, - BountyId: bounty.ID, - Person: bountyOwner, - BountyCreated: bounty.Created, - BountyDescription: bounty.Description, - BountyUpdated: bounty.Updated, - AssigneeId: bountyAssignee.ID, - AssigneeImg: bountyAssignee.Img, - AssigneeAlias: bountyAssignee.OwnerAlias, - AssigneeDescription: bountyAssignee.Description, - AssigneeRouteHint: bountyAssignee.OwnerRouteHint, - BountyOwnerId: bountyOwner.ID, - OwnerUuid: bountyOwner.Uuid, - OwnerDescription: bountyOwner.Description, - OwnerUniqueName: bountyOwner.UniqueName, - OwnerImg: bountyOwner.Img, - OrganizationName: organization.Name, - OrganizationImg: organization.Img, - OrganizationUuid: organization.Uuid, - OrganizationDescription: organization.Description, + Bounty: bounty, + BountyId: bounty.ID, + Person: bountyOwner, + BountyCreated: bounty.Created, + BountyDescription: bounty.Description, + BountyUpdated: bounty.Updated, + AssigneeId: bountyAssignee.ID, + AssigneeImg: bountyAssignee.Img, + AssigneeAlias: bountyAssignee.OwnerAlias, + AssigneeDescription: bountyAssignee.Description, + AssigneeRouteHint: bountyAssignee.OwnerRouteHint, + BountyOwnerId: bountyOwner.ID, + OwnerUuid: bountyOwner.Uuid, + OwnerDescription: bountyOwner.Description, + OwnerUniqueName: bountyOwner.UniqueName, + OwnerImg: bountyOwner.Img, + OrganizationName: organization.Name, + OrganizationImg: organization.Img, + WorkspaceUuid: organization.Uuid, + WorkspaceDescription: organization.Description, } metricBountiesData = append(metricBountiesData, bountyData) } @@ -339,7 +339,7 @@ func getMetricsBountyCsv(metricBounties []db.Bounty) []db.MetricsBountyCsv { for _, bounty := range metricBounties { bountyOwner := db.DB.GetPersonByPubkey(bounty.OwnerID) bountyAssignee := db.DB.GetPersonByPubkey(bounty.Assignee) - organization := db.DB.GetOrganizationByUuid(bounty.OrgUuid) + organization := db.DB.GetWorkspaceByUuid(bounty.OrgUuid) bountyLink := fmt.Sprintf("https://community.sphinx.chat/bounty/%d", bounty.ID) bountyStatus := "Open" @@ -372,7 +372,7 @@ func getMetricsBountyCsv(metricBounties []db.Bounty) []db.MetricsBountyCsv { func ConvertMetricsToCSV(metricBountiesData []db.MetricsBountyCsv) [][]string { metricsData := db.DB.ConvertMetricsBountiesToMap(metricBountiesData) opts := &jsonconv.ToCsvOption{ - BaseHeaders: []string{"DatePosted", "Organization", "BountyAmount", "Provider", "Hunter", "BountyTitle", "BountyLink", "BountyStatus", "DateAssigned", "DatePaid"}, + BaseHeaders: []string{"DatePosted", "Workspace", "BountyAmount", "Provider", "Hunter", "BountyTitle", "BountyLink", "BountyStatus", "DateAssigned", "DatePaid"}, } result := jsonconv.ToCsv(metricsData, opts) return result diff --git a/handlers/metrics_test.go b/handlers/metrics_test.go index c00de596d..087101143 100644 --- a/handlers/metrics_test.go +++ b/handlers/metrics_test.go @@ -161,7 +161,7 @@ func TestMetricsBounties(t *testing.T) { mockDb.On("GetBountiesByDateRange", dateRange, req).Return(bounties).Once() mockDb.On("GetPersonByPubkey", "owner-1").Return(db.Person{ID: 1}).Once() mockDb.On("GetPersonByPubkey", "").Return(db.Person{}).Once() - mockDb.On("GetOrganizationByUuid", "").Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByUuid", "").Return(db.Organization{}).Once() handler.ServeHTTP(rr, req) var res []db.BountyData @@ -216,10 +216,10 @@ func TestMetricsBounties(t *testing.T) { mockDb.On("GetBountiesByDateRange", dateRange, req).Return(bounties).Once() mockDb.On("GetPersonByPubkey", "provider1").Return(db.Person{ID: 1}).Once() mockDb.On("GetPersonByPubkey", "").Return(db.Person{}).Once() - mockDb.On("GetOrganizationByUuid", "").Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByUuid", "").Return(db.Organization{}).Once() mockDb.On("GetPersonByPubkey", "provider2").Return(db.Person{ID: 2}).Once() mockDb.On("GetPersonByPubkey", "").Return(db.Person{}).Once() - mockDb.On("GetOrganizationByUuid", "").Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByUuid", "").Return(db.Organization{}).Once() handler.ServeHTTP(rr, req) @@ -338,7 +338,7 @@ func TestConvertMetricsToCSV(t *testing.T) { DatePaid: &now, DateAssigned: &now, }} - expectedHeaders := []string{"DatePosted", "Organization", "BountyAmount", "Provider", "Hunter", "BountyTitle", "BountyLink", "BountyStatus", "DateAssigned", "DatePaid"} + expectedHeaders := []string{"DatePosted", "Workspace", "BountyAmount", "Provider", "Hunter", "BountyTitle", "BountyLink", "BountyStatus", "DateAssigned", "DatePaid"} results := ConvertMetricsToCSV(bounties) assert.Equal(t, 2, len(results)) diff --git a/handlers/organizations.go b/handlers/workspaces.go similarity index 72% rename from handlers/organizations.go rename to handlers/workspaces.go index e91056fa5..8922ce63f 100644 --- a/handlers/organizations.go +++ b/handlers/workspaces.go @@ -16,7 +16,7 @@ import ( "gorm.io/gorm" ) -type organizationHandler struct { +type workspaceHandler struct { db db.Database generateBountyHandler func(bounties []db.Bounty) []db.BountyResponse getLightningInvoice func(payment_request string) (db.InvoiceResult, db.InvoiceError) @@ -24,10 +24,10 @@ type organizationHandler struct { userHasManageBountyRoles func(pubKeyFromAuth string, uuid string) bool } -func NewOrganizationHandler(database db.Database) *organizationHandler { +func NewWorkspaceHandler(database db.Database) *workspaceHandler { bHandler := NewBountyHandler(http.DefaultClient, database) dbConf := db.NewDatabaseConfig(&gorm.DB{}) - return &organizationHandler{ + return &workspaceHandler{ db: database, generateBountyHandler: bHandler.GenerateBountyResponse, getLightningInvoice: bHandler.GetLightningInvoice, @@ -36,7 +36,7 @@ func NewOrganizationHandler(database db.Database) *organizationHandler { } } -func (oh *organizationHandler) CreateOrEditOrganization(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) CreateOrEditWorkspace(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) if pubKeyFromAuth == "" { @@ -46,10 +46,10 @@ func (oh *organizationHandler) CreateOrEditOrganization(w http.ResponseWriter, r } now := time.Now() - org := db.Organization{} - body, err := io.ReadAll(r.Body) + workspace := db.Organization{} + body, _ := io.ReadAll(r.Body) r.Body.Close() - err = json.Unmarshal(body, &org) + err := json.Unmarshal(body, &workspace) if err != nil { fmt.Println(err) @@ -57,36 +57,36 @@ func (oh *organizationHandler) CreateOrEditOrganization(w http.ResponseWriter, r return } - org.Name = strings.TrimSpace(org.Name) + workspace.Name = strings.TrimSpace(workspace.Name) - if len(org.Name) == 0 || len(org.Name) > 20 { - fmt.Printf("invalid organization name %s\n", org.Name) + if len(workspace.Name) == 0 || len(workspace.Name) > 20 { + fmt.Printf("invalid organization name %s\n", workspace.Name) w.WriteHeader(http.StatusBadRequest) json.NewEncoder(w).Encode("Error: organization name must be present and should not exceed 20 character") return } - if len(org.Description) > 120 { - fmt.Printf("invalid organization name %s\n", org.Description) + if len(workspace.Description) > 120 { + fmt.Printf("invalid organization name %s\n", workspace.Description) w.WriteHeader(http.StatusBadRequest) json.NewEncoder(w).Encode("Error: organization description should not exceed 120 character") return } - if pubKeyFromAuth != org.OwnerPubKey { - hasRole := db.UserHasAccess(pubKeyFromAuth, org.Uuid, db.EditOrg) + if pubKeyFromAuth != workspace.OwnerPubKey { + hasRole := db.UserHasAccess(pubKeyFromAuth, workspace.Uuid, db.EditOrg) if !hasRole { fmt.Println(pubKeyFromAuth) - fmt.Println(org.OwnerPubKey) + fmt.Println(workspace.OwnerPubKey) fmt.Println("mismatched pubkey") w.WriteHeader(http.StatusUnauthorized) - json.NewEncoder(w).Encode("Don't have access to Edit Org") + json.NewEncoder(w).Encode("Don't have access to Edit workspace") return } } // Validate struct data - err = db.Validate.Struct(org) + err = db.Validate.Struct(workspace) if err != nil { w.WriteHeader(http.StatusBadRequest) msg := fmt.Sprintf("Error: did not pass validation test : %s", err) @@ -94,52 +94,52 @@ func (oh *organizationHandler) CreateOrEditOrganization(w http.ResponseWriter, r return } - if org.Github != "" && !strings.Contains(org.Github, "github.com/") { + if workspace.Github != "" && !strings.Contains(workspace.Github, "github.com/") { w.WriteHeader(http.StatusBadRequest) msg := "Error: not a valid github" json.NewEncoder(w).Encode(msg) return } - existing := oh.db.GetOrganizationByUuid(org.Uuid) + existing := oh.db.GetWorkspaceByUuid(workspace.Uuid) if existing.ID == 0 { // new! - if org.ID != 0 { // can't try to "edit" if it does not exist already + if workspace.ID != 0 { // can't try to "edit" if it does not exist already fmt.Println("cant edit non existing") w.WriteHeader(http.StatusUnauthorized) return } - name := org.Name + name := workspace.Name // check if the organization name already exists - orgName := oh.db.GetOrganizationByName(name) + orgName := oh.db.GetWorkspaceByName(name) if orgName.Name == name { w.WriteHeader(http.StatusUnauthorized) - json.NewEncoder(w).Encode("Organization name already exists") + json.NewEncoder(w).Encode("Workspace name already exists") return } else { - org.Created = &now - org.Updated = &now - org.Uuid = xid.New().String() - org.Name = name + workspace.Created = &now + workspace.Updated = &now + workspace.Uuid = xid.New().String() + workspace.Name = name } } else { - if org.ID == 0 { + if workspace.ID == 0 { // can't create that already exists fmt.Println("can't create existing organization") w.WriteHeader(http.StatusUnauthorized) return } - if org.ID != existing.ID { // can't edit someone else's + if workspace.ID != existing.ID { // can't edit someone else's fmt.Println("cant edit another organization") w.WriteHeader(http.StatusUnauthorized) return } } - p, err := oh.db.CreateOrEditOrganization(org) + p, err := oh.db.CreateOrEditWorkspace(workspace) if err != nil { w.WriteHeader(http.StatusBadRequest) return @@ -149,29 +149,29 @@ func (oh *organizationHandler) CreateOrEditOrganization(w http.ResponseWriter, r json.NewEncoder(w).Encode(p) } -func GetOrganizations(w http.ResponseWriter, r *http.Request) { - orgs := db.DB.GetOrganizations(r) +func GetWorkspaces(w http.ResponseWriter, r *http.Request) { + orgs := db.DB.GetWorkspaces(r) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(orgs) } -func GetOrganizationsCount(w http.ResponseWriter, r *http.Request) { - count := db.DB.GetOrganizationsCount() +func GetWorkspacesCount(w http.ResponseWriter, r *http.Request) { + count := db.DB.GetWorkspacesCount() w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(count) } -func GetOrganizationByUuid(w http.ResponseWriter, r *http.Request) { +func GetWorkspaceByUuid(w http.ResponseWriter, r *http.Request) { uuid := chi.URLParam(r, "uuid") - org := db.DB.GetOrganizationByUuid(uuid) + workspace := db.DB.GetWorkspaceByUuid(uuid) w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(org) + json.NewEncoder(w).Encode(workspace) } -func CreateOrganizationUser(w http.ResponseWriter, r *http.Request) { +func CreateWorkspaceUser(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) now := time.Now() @@ -182,7 +182,7 @@ func CreateOrganizationUser(w http.ResponseWriter, r *http.Request) { err = json.Unmarshal(body, &orgUser) // get orgnanization - org := db.DB.GetOrganizationByUuid(orgUser.OrgUuid) + workspace := db.DB.GetWorkspaceByUuid(orgUser.OrgUuid) if err != nil { fmt.Println(err) @@ -197,7 +197,7 @@ func CreateOrganizationUser(w http.ResponseWriter, r *http.Request) { } // check if the user is the organization admin - if orgUser.OwnerPubKey == org.OwnerPubKey { + if orgUser.OwnerPubKey == workspace.OwnerPubKey { w.WriteHeader(http.StatusUnauthorized) json.NewEncoder(w).Encode("Cannot add organization admin as a user") return @@ -227,7 +227,7 @@ func CreateOrganizationUser(w http.ResponseWriter, r *http.Request) { } // check if user already exists - userExists := db.DB.GetOrganizationUser(orgUser.OwnerPubKey, orgUser.OrgUuid) + userExists := db.DB.GetWorkspaceUser(orgUser.OwnerPubKey, orgUser.OrgUuid) if userExists.ID != 0 { w.WriteHeader(http.StatusUnauthorized) @@ -239,20 +239,20 @@ func CreateOrganizationUser(w http.ResponseWriter, r *http.Request) { orgUser.Updated = &now // create user - user := db.DB.CreateOrganizationUser(orgUser) + user := db.DB.CreateWorkspaceUser(orgUser) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(user) } -func GetOrganizationUsers(w http.ResponseWriter, r *http.Request) { +func GetWorkspaceUsers(w http.ResponseWriter, r *http.Request) { uuid := chi.URLParam(r, "uuid") - orgUsers, _ := db.DB.GetOrganizationUsers(uuid) + orgUsers, _ := db.DB.GetWorkspaceUsers(uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(orgUsers) } -func GetOrganizationUser(w http.ResponseWriter, r *http.Request) { +func GetWorkspaceUser(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) @@ -263,21 +263,21 @@ func GetOrganizationUser(w http.ResponseWriter, r *http.Request) { } uuid := chi.URLParam(r, "uuid") - orgUser := db.DB.GetOrganizationUser(pubKeyFromAuth, uuid) + orgUser := db.DB.GetWorkspaceUser(pubKeyFromAuth, uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(orgUser) } -func GetOrganizationUsersCount(w http.ResponseWriter, r *http.Request) { +func GetWorkspaceUsersCount(w http.ResponseWriter, r *http.Request) { uuid := chi.URLParam(r, "uuid") - count := db.DB.GetOrganizationUsersCount(uuid) + count := db.DB.GetWorkspaceUsersCount(uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(count) } -func DeleteOrganizationUser(w http.ResponseWriter, r *http.Request) { +func DeleteWorkspaceUser(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) @@ -298,9 +298,9 @@ func DeleteOrganizationUser(w http.ResponseWriter, r *http.Request) { return } - org := db.DB.GetOrganizationByUuid(orgUser.OrgUuid) + workspace := db.DB.GetWorkspaceByUuid(orgUser.OrgUuid) - if orgUser.OwnerPubKey == org.OwnerPubKey { + if orgUser.OwnerPubKey == workspace.OwnerPubKey { w.WriteHeader(http.StatusUnauthorized) json.NewEncoder(w).Encode("Cannot delete organization admin") return @@ -313,7 +313,7 @@ func DeleteOrganizationUser(w http.ResponseWriter, r *http.Request) { return } - db.DB.DeleteOrganizationUser(orgUser, orgUser.OrgUuid) + db.DB.DeleteWorkspaceUser(orgUser, orgUser.OrgUuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(orgUser) @@ -405,7 +405,7 @@ func AddUserRoles(w http.ResponseWriter, r *http.Request) { } // check if user already exists - userExists := db.DB.GetOrganizationUser(user, uuid) + userExists := db.DB.GetWorkspaceUser(user, uuid) // if not the organization admin if userExists.OwnerPubKey != user || userExists.OrgUuid != uuid { @@ -430,7 +430,7 @@ func GetUserRoles(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(userRoles) } -func GetUserOrganizations(w http.ResponseWriter, r *http.Request) { +func GetUserWorkspaces(w http.ResponseWriter, r *http.Request) { userIdParam := chi.URLParam(r, "userId") userId, _ := utils.ConvertStringToUint(userIdParam) @@ -442,36 +442,36 @@ func GetUserOrganizations(w http.ResponseWriter, r *http.Request) { user := db.DB.GetPerson(userId) - // get the organizations created by the user, then get all the organizations + // get the workspaces created by the user, then get all the workspaces // the user has been added to, loop through to get the organization - organizations := GetCreatedOrganizations(user.OwnerPubKey) + workspaces := GetCreatedWorkspaces(user.OwnerPubKey) - assignedOrganizations := db.DB.GetUserAssignedOrganizations(user.OwnerPubKey) - for _, value := range assignedOrganizations { + assignedWorkspaces := db.DB.GetUserAssignedWorkspaces(user.OwnerPubKey) + for _, value := range assignedWorkspaces { uuid := value.OrgUuid - organization := db.DB.GetOrganizationByUuid(uuid) - bountyCount := db.DB.GetOrganizationBountyCount(uuid) + organization := db.DB.GetWorkspaceByUuid(uuid) + bountyCount := db.DB.GetWorkspaceBountyCount(uuid) hasRole := db.UserHasAccess(user.OwnerPubKey, uuid, db.ViewReport) - // don't add deleted organizations to the list + // don't add deleted workspaces to the list if !organization.Deleted { if hasRole { - budget := db.DB.GetOrganizationBudget(uuid) + budget := db.DB.GetWorkspaceBudget(uuid) organization.Budget = budget.TotalBudget } else { organization.Budget = 0 } organization.BountyCount = bountyCount - organizations = append(organizations, organization) + workspaces = append(workspaces, organization) } } w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(organizations) + json.NewEncoder(w).Encode(workspaces) } -func (oh *organizationHandler) GetUserDropdownOrganizations(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) GetUserDropdownWorkspaces(w http.ResponseWriter, r *http.Request) { userIdParam := chi.URLParam(r, "userId") userId, _ := utils.ConvertStringToUint(userIdParam) @@ -483,76 +483,76 @@ func (oh *organizationHandler) GetUserDropdownOrganizations(w http.ResponseWrite user := db.DB.GetPerson(userId) - // get the organizations created by the user, then get all the organizations + // get the workspaces created by the user, then get all the workspaces // the user has been added to, loop through to get the organization - organizations := GetCreatedOrganizations(user.OwnerPubKey) + workspaces := GetCreatedWorkspaces(user.OwnerPubKey) - assignedOrganizations := db.DB.GetUserAssignedOrganizations(user.OwnerPubKey) - for _, value := range assignedOrganizations { + assignedWorkspaces := db.DB.GetUserAssignedWorkspaces(user.OwnerPubKey) + for _, value := range assignedWorkspaces { uuid := value.OrgUuid - organization := db.DB.GetOrganizationByUuid(uuid) - bountyCount := db.DB.GetOrganizationBountyCount(uuid) + organization := db.DB.GetWorkspaceByUuid(uuid) + bountyCount := db.DB.GetWorkspaceBountyCount(uuid) hasRole := db.UserHasAccess(user.OwnerPubKey, uuid, db.ViewReport) hasBountyRoles := oh.userHasManageBountyRoles(user.OwnerPubKey, uuid) - // don't add deleted organizations to the list + // don't add deleted workspaces to the list if !organization.Deleted && hasBountyRoles { if hasRole { - budget := db.DB.GetOrganizationBudget(uuid) + budget := db.DB.GetWorkspaceBudget(uuid) organization.Budget = budget.TotalBudget } else { organization.Budget = 0 } organization.BountyCount = bountyCount - organizations = append(organizations, organization) + workspaces = append(workspaces, organization) } } w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(organizations) + json.NewEncoder(w).Encode(workspaces) } -func GetCreatedOrganizations(pubkey string) []db.Organization { - organizations := db.DB.GetUserCreatedOrganizations(pubkey) +func GetCreatedWorkspaces(pubkey string) []db.Organization { + workspaces := db.DB.GetUserCreatedWorkspaces(pubkey) // add bounty count to the organization - for index, value := range organizations { + for index, value := range workspaces { uuid := value.Uuid - bountyCount := db.DB.GetOrganizationBountyCount(uuid) + bountyCount := db.DB.GetWorkspaceBountyCount(uuid) hasRole := db.UserHasAccess(pubkey, uuid, db.ViewReport) if hasRole { - budget := db.DB.GetOrganizationBudget(uuid) - organizations[index].Budget = budget.TotalBudget + budget := db.DB.GetWorkspaceBudget(uuid) + workspaces[index].Budget = budget.TotalBudget } else { - organizations[index].Budget = 0 + workspaces[index].Budget = 0 } - organizations[index].BountyCount = bountyCount + workspaces[index].BountyCount = bountyCount } - return organizations + return workspaces } -func (oh *organizationHandler) GetOrganizationBounties(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) GetWorkspaceBounties(w http.ResponseWriter, r *http.Request) { uuid := chi.URLParam(r, "uuid") // get the organization bounties - organizationBounties := oh.db.GetOrganizationBounties(r, uuid) + organizationBounties := oh.db.GetWorkspaceBounties(r, uuid) var bountyResponse []db.BountyResponse = oh.generateBountyHandler(organizationBounties) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(bountyResponse) } -func (oh *organizationHandler) GetOrganizationBountiesCount(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) GetWorkspaceBountiesCount(w http.ResponseWriter, r *http.Request) { uuid := chi.URLParam(r, "uuid") - organizationBountiesCount := oh.db.GetOrganizationBountiesCount(r, uuid) + organizationBountiesCount := oh.db.GetWorkspaceBountiesCount(r, uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(organizationBountiesCount) } -func (oh *organizationHandler) GetOrganizationBudget(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) GetWorkspaceBudget(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) uuid := chi.URLParam(r, "uuid") @@ -572,13 +572,13 @@ func (oh *organizationHandler) GetOrganizationBudget(w http.ResponseWriter, r *h } // get the organization budget - organizationBudget := oh.db.GetOrganizationStatusBudget(uuid) + organizationBudget := oh.db.GetWorkspaceStatusBudget(uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(organizationBudget) } -func (oh *organizationHandler) GetOrganizationBudgetHistory(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) GetWorkspaceBudgetHistory(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) uuid := chi.URLParam(r, "uuid") @@ -592,7 +592,7 @@ func (oh *organizationHandler) GetOrganizationBudgetHistory(w http.ResponseWrite } // get the organization budget - organizationBudget := oh.db.GetOrganizationBudgetHistory(uuid) + organizationBudget := oh.db.GetWorkspaceBudgetHistory(uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(organizationBudget) @@ -638,7 +638,7 @@ func GetPaymentHistory(w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(paymentHistoryData) } -func (oh *organizationHandler) PollBudgetInvoices(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) PollBudgetInvoices(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) uuid := chi.URLParam(r, "uuid") @@ -649,7 +649,7 @@ func (oh *organizationHandler) PollBudgetInvoices(w http.ResponseWriter, r *http return } - orgInvoices := oh.db.GetOrganizationInvoices(uuid) + orgInvoices := oh.db.GetWorkspaceInvoices(uuid) for _, inv := range orgInvoices { invoiceRes, invoiceErr := oh.getLightningInvoice(inv.PaymentRequest) @@ -684,12 +684,12 @@ func GetInvoicesCount(w http.ResponseWriter, r *http.Request) { return } - invoiceCount := db.DB.GetOrganizationInvoicesCount(uuid) + invoiceCount := db.DB.GetWorkspaceInvoicesCount(uuid) w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(invoiceCount) } -func (oh *organizationHandler) DeleteOrganization(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) DeleteWorkspace(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) uuid := chi.URLParam(r, "uuid") @@ -700,10 +700,10 @@ func (oh *organizationHandler) DeleteOrganization(w http.ResponseWriter, r *http return } - organization := oh.db.GetOrganizationByUuid(uuid) + organization := oh.db.GetWorkspaceByUuid(uuid) if pubKeyFromAuth != organization.OwnerPubKey { - msg := "only org admin can delete an organization" + msg := "only workspace admin can delete an organization" fmt.Println(msg) w.WriteHeader(http.StatusUnauthorized) json.NewEncoder(w).Encode(msg) @@ -711,21 +711,21 @@ func (oh *organizationHandler) DeleteOrganization(w http.ResponseWriter, r *http } // Update organization to hide and clear certain fields - if err := oh.db.UpdateOrganizationForDeletion(uuid); err != nil { + if err := oh.db.UpdateWorkspaceForDeletion(uuid); err != nil { fmt.Println("Error updating organization:", err) w.WriteHeader(http.StatusInternalServerError) return } // Delete all users from the organization - if err := oh.db.DeleteAllUsersFromOrganization(uuid); err != nil { + if err := oh.db.DeleteAllUsersFromWorkspace(uuid); err != nil { fmt.Println("Error removing users from organization:", err) w.WriteHeader(http.StatusInternalServerError) return } // soft delete organization - org := oh.db.ChangeOrganizationDeleteStatus(uuid, true) + workspace := oh.db.ChangeWorkspaceDeleteStatus(uuid, true) w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(org) + json.NewEncoder(w).Encode(workspace) } diff --git a/handlers/organization_test.go b/handlers/workspaces_test.go similarity index 72% rename from handlers/organization_test.go rename to handlers/workspaces_test.go index 017955cdd..8630709b6 100644 --- a/handlers/organization_test.go +++ b/handlers/workspaces_test.go @@ -19,14 +19,14 @@ import ( "github.com/stretchr/testify/mock" ) -func TestUnitCreateOrEditOrganization(t *testing.T) { +func TestUnitCreateOrEditWorkspace(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := mocks.NewDatabase(t) - oHandler := NewOrganizationHandler(mockDb) + oHandler := NewWorkspaceHandler(mockDb) t.Run("should return error if body is not a valid json", func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) invalidJson := []byte(`{"key": "value"`) @@ -43,7 +43,7 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { t.Run("should return error if public key not present", func(t *testing.T) { //passed rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) invalidJson := []byte(`{"key": "value"}`) req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, "/", bytes.NewReader(invalidJson)) @@ -58,7 +58,7 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { t.Run("should return error org name is empty", func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) invalidJson := []byte(`{"name": ""}`) req, err := http.NewRequestWithContext(ctx, http.MethodPost, "/", bytes.NewReader(invalidJson)) @@ -73,9 +73,9 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { t.Run("should return error org name is more than 20", func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) - invalidJson := []byte(`{"name": "DemoTestingOrganization"}`) + invalidJson := []byte(`{"name": "DemoTestingNewWorkspace"}`) req, err := http.NewRequestWithContext(ctx, http.MethodPost, "/", bytes.NewReader(invalidJson)) if err != nil { t.Fatal(err) @@ -88,7 +88,7 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { t.Run("should return error if org name contains only spaces", func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) invalidJson := []byte(`{"name": " "}`) req, err := http.NewRequestWithContext(ctx, http.MethodPost, "/", bytes.NewReader(invalidJson)) @@ -103,11 +103,11 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { t.Run("should trim spaces from organization name", func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) - mockDb.On("GetOrganizationByUuid", mock.AnythingOfType("string")).Return(db.Organization{}).Once() - mockDb.On("GetOrganizationByName", "Abdul").Return(db.Organization{}).Once() - mockDb.On("CreateOrEditOrganization", mock.MatchedBy(func(org db.Organization) bool { + mockDb.On("GetWorkspaceByUuid", mock.AnythingOfType("string")).Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByName", "Abdul").Return(db.Organization{}).Once() + mockDb.On("CreateOrEditWorkspace", mock.MatchedBy(func(org db.Organization) bool { return org.Name == "Abdul" && org.Uuid != "" && org.Updated != nil && org.Created != nil })).Return(db.Organization{Name: "Abdul"}, nil).Once() @@ -132,15 +132,15 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { t.Run("should successfully add organization if request is valid", func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) - mockDb.On("GetOrganizationByUuid", mock.AnythingOfType("string")).Return(db.Organization{}).Once() - mockDb.On("GetOrganizationByName", "TestOrganization").Return(db.Organization{}).Once() - mockDb.On("CreateOrEditOrganization", mock.MatchedBy(func(org db.Organization) bool { - return org.Name == "TestOrganization" && org.Uuid != "" && org.Updated != nil && org.Created != nil + mockDb.On("GetWorkspaceByUuid", mock.AnythingOfType("string")).Return(db.Organization{}).Once() + mockDb.On("GetWorkspaceByName", "TestWorkspace").Return(db.Organization{}).Once() + mockDb.On("CreateOrEditWorkspace", mock.MatchedBy(func(org db.Organization) bool { + return org.Name == "TestWorkspace" && org.Uuid != "" && org.Updated != nil && org.Created != nil })).Return(db.Organization{}, nil).Once() - invalidJson := []byte(`{"name": "TestOrganization", "owner_pubkey": "test-key" ,"description": "Test"}`) + invalidJson := []byte(`{"name": "TestWorkspace", "owner_pubkey": "test-key" ,"description": "Test"}`) req, err := http.NewRequestWithContext(ctx, http.MethodPost, "/", bytes.NewReader(invalidJson)) if err != nil { t.Fatal(err) @@ -162,8 +162,8 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.CreateOrEditOrganization) - invalidJson := []byte(fmt.Sprintf(`{"name": "TestOrganization", "owner_pubkey": "test-key", "description": "%s"}`, tc.description)) + handler := http.HandlerFunc(oHandler.CreateOrEditWorkspace) + invalidJson := []byte(fmt.Sprintf(`{"name": "TestWorkspace", "owner_pubkey": "test-key", "description": "%s"}`, tc.description)) req, err := http.NewRequestWithContext(ctx, http.MethodPost, "/", bytes.NewReader(invalidJson)) if err != nil { @@ -178,15 +178,15 @@ func TestUnitCreateOrEditOrganization(t *testing.T) { }) } -func TestDeleteOrganization(t *testing.T) { +func TestDeleteWorkspace(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := mocks.NewDatabase(t) - oHandler := NewOrganizationHandler(mockDb) + oHandler := NewWorkspaceHandler(mockDb) t.Run("should return error if not authorized", func(t *testing.T) { orgUUID := "org-uuid" rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.DeleteOrganization) + handler := http.HandlerFunc(oHandler.DeleteWorkspace) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -204,13 +204,13 @@ func TestDeleteOrganization(t *testing.T) { orgUUID := "org-uuid" // Mock expected database interactions - mockDb.On("GetOrganizationByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() - mockDb.On("UpdateOrganizationForDeletion", orgUUID).Return(nil).Once() - mockDb.On("DeleteAllUsersFromOrganization", orgUUID).Return(nil).Once() - mockDb.On("ChangeOrganizationDeleteStatus", orgUUID, true).Return(db.Organization{Uuid: orgUUID, Deleted: true}).Once() + mockDb.On("GetWorkspaceByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() + mockDb.On("UpdateWorkspaceForDeletion", orgUUID).Return(nil).Once() + mockDb.On("DeleteAllUsersFromWorkspace", orgUUID).Return(nil).Once() + mockDb.On("ChangeWorkspaceDeleteStatus", orgUUID, true).Return(db.Organization{Uuid: orgUUID, Deleted: true}).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.DeleteOrganization) + handler := http.HandlerFunc(oHandler.DeleteWorkspace) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -229,11 +229,11 @@ func TestDeleteOrganization(t *testing.T) { orgUUID := "org-uuid" // Mock database interactions with error - mockDb.On("GetOrganizationByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() - mockDb.On("UpdateOrganizationForDeletion", orgUUID).Return(errors.New("update error")).Once() + mockDb.On("GetWorkspaceByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() + mockDb.On("UpdateWorkspaceForDeletion", orgUUID).Return(errors.New("update error")).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.DeleteOrganization) + handler := http.HandlerFunc(oHandler.DeleteWorkspace) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -252,13 +252,13 @@ func TestDeleteOrganization(t *testing.T) { orgUUID := "org-uuid" // Mock the database interactions - mockDb.On("GetOrganizationByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() - mockDb.On("UpdateOrganizationForDeletion", orgUUID).Return(nil).Once() - mockDb.On("DeleteAllUsersFromOrganization", orgUUID).Return(nil).Once() - mockDb.On("ChangeOrganizationDeleteStatus", orgUUID, true).Return(db.Organization{Uuid: orgUUID, Deleted: true}).Once() + mockDb.On("GetWorkspaceByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() + mockDb.On("UpdateWorkspaceForDeletion", orgUUID).Return(nil).Once() + mockDb.On("DeleteAllUsersFromWorkspace", orgUUID).Return(nil).Once() + mockDb.On("ChangeWorkspaceDeleteStatus", orgUUID, true).Return(db.Organization{Uuid: orgUUID, Deleted: true}).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.DeleteOrganization) + handler := http.HandlerFunc(oHandler.DeleteWorkspace) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -294,13 +294,13 @@ func TestDeleteOrganization(t *testing.T) { Description: "", } - mockDb.On("GetOrganizationByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() - mockDb.On("UpdateOrganizationForDeletion", orgUUID).Return(nil).Once() - mockDb.On("DeleteAllUsersFromOrganization", orgUUID).Return(nil).Once() - mockDb.On("ChangeOrganizationDeleteStatus", orgUUID, true).Return(updatedOrg).Once() + mockDb.On("GetWorkspaceByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() + mockDb.On("UpdateWorkspaceForDeletion", orgUUID).Return(nil).Once() + mockDb.On("DeleteAllUsersFromWorkspace", orgUUID).Return(nil).Once() + mockDb.On("ChangeWorkspaceDeleteStatus", orgUUID, true).Return(updatedOrg).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.DeleteOrganization) + handler := http.HandlerFunc(oHandler.DeleteWorkspace) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -328,13 +328,13 @@ func TestDeleteOrganization(t *testing.T) { orgUUID := "org-uuid" // Setting up the expected behavior of the mock database - mockDb.On("GetOrganizationByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() - mockDb.On("UpdateOrganizationForDeletion", orgUUID).Return(nil).Once() - mockDb.On("DeleteAllUsersFromOrganization", orgUUID).Return(nil).Run(func(args mock.Arguments) {}).Once() - mockDb.On("ChangeOrganizationDeleteStatus", orgUUID, true).Return(db.Organization{Uuid: orgUUID, Deleted: true}).Once() + mockDb.On("GetWorkspaceByUuid", orgUUID).Return(db.Organization{OwnerPubKey: "test-key"}).Once() + mockDb.On("UpdateWorkspaceForDeletion", orgUUID).Return(nil).Once() + mockDb.On("DeleteAllUsersFromWorkspace", orgUUID).Return(nil).Run(func(args mock.Arguments) {}).Once() + mockDb.On("ChangeWorkspaceDeleteStatus", orgUUID, true).Return(db.Organization{Uuid: orgUUID, Deleted: true}).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.DeleteOrganization) + handler := http.HandlerFunc(oHandler.DeleteWorkspace) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -351,23 +351,23 @@ func TestDeleteOrganization(t *testing.T) { }) } -func TestGetOrganizationBounties(t *testing.T) { +func TestGetWorkspaceBounties(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := mocks.NewDatabase(t) mockGenerateBountyHandler := func(bounties []db.Bounty) []db.BountyResponse { return []db.BountyResponse{} // Mocked response } - oHandler := NewOrganizationHandler(mockDb) + oHandler := NewWorkspaceHandler(mockDb) t.Run("Should test that an organization's bounties can be listed without authentication", func(t *testing.T) { orgUUID := "valid-uuid" oHandler.generateBountyHandler = mockGenerateBountyHandler expectedBounties := []db.Bounty{{}, {}} // Mocked response - mockDb.On("GetOrganizationBounties", mock.AnythingOfType("*http.Request"), orgUUID).Return(expectedBounties).Once() + mockDb.On("GetWorkspaceBounties", mock.AnythingOfType("*http.Request"), orgUUID).Return(expectedBounties).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.GetOrganizationBounties) + handler := http.HandlerFunc(oHandler.GetWorkspaceBounties) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -384,10 +384,10 @@ func TestGetOrganizationBounties(t *testing.T) { t.Run("should return empty array when wrong organization UUID is passed", func(t *testing.T) { orgUUID := "wrong-uuid" - mockDb.On("GetOrganizationBounties", mock.AnythingOfType("*http.Request"), orgUUID).Return([]db.Bounty{}).Once() + mockDb.On("GetWorkspaceBounties", mock.AnythingOfType("*http.Request"), orgUUID).Return([]db.Bounty{}).Once() rr := httptest.NewRecorder() - handler := http.HandlerFunc(oHandler.GetOrganizationBounties) + handler := http.HandlerFunc(oHandler.GetWorkspaceBounties) rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -406,13 +406,13 @@ func TestGetOrganizationBounties(t *testing.T) { }) } -func TestGetOrganizationBudget(t *testing.T) { +func TestGetWorkspaceBudget(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := mocks.NewDatabase(t) mockUserHasAccess := func(pubKeyFromAuth string, uuid string, role string) bool { return true } - oHandler := NewOrganizationHandler(mockDb) + oHandler := NewWorkspaceHandler(mockDb) t.Run("Should test that a 401 is returned when trying to view an organization's budget without a token", func(t *testing.T) { orgUUID := "valid-uuid" @@ -425,12 +425,12 @@ func TestGetOrganizationBudget(t *testing.T) { } rr := httptest.NewRecorder() - http.HandlerFunc(oHandler.GetOrganizationBudget).ServeHTTP(rr, req) + http.HandlerFunc(oHandler.GetWorkspaceBudget).ServeHTTP(rr, req) assert.Equal(t, http.StatusUnauthorized, rr.Code) }) - t.Run("Should test that the right organization budget is returned, if the user is the organization admin or has the ViewReport role", func(t *testing.T) { + t.Run("Should test that the right workspace budget is returned, if the user is the organization admin or has the ViewReport role", func(t *testing.T) { orgUUID := "valid-uuid" statusBudget := db.StatusBudget{ OrgUuid: orgUUID, @@ -441,7 +441,7 @@ func TestGetOrganizationBudget(t *testing.T) { } oHandler.userHasAccess = mockUserHasAccess - mockDb.On("GetOrganizationStatusBudget", orgUUID).Return(statusBudget).Once() + mockDb.On("GetWorkspaceStatusBudget", orgUUID).Return(statusBudget).Once() rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -451,7 +451,7 @@ func TestGetOrganizationBudget(t *testing.T) { } rr := httptest.NewRecorder() - http.HandlerFunc(oHandler.GetOrganizationBudget).ServeHTTP(rr, req) + http.HandlerFunc(oHandler.GetWorkspaceBudget).ServeHTTP(rr, req) assert.Equal(t, http.StatusOK, rr.Code) @@ -465,10 +465,10 @@ func TestGetOrganizationBudget(t *testing.T) { }) } -func TestGetOrganizationBudgetHistory(t *testing.T) { +func TestGetWorkspaceBudgetHistory(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := mocks.NewDatabase(t) - oHandler := NewOrganizationHandler(mockDb) + oHandler := NewWorkspaceHandler(mockDb) t.Run("Should test that a 401 is returned when trying to view an organization's budget history without a token", func(t *testing.T) { orgUUID := "valid-uuid" @@ -486,7 +486,7 @@ func TestGetOrganizationBudgetHistory(t *testing.T) { } rr := httptest.NewRecorder() - http.HandlerFunc(oHandler.GetOrganizationBudgetHistory).ServeHTTP(rr, req) + http.HandlerFunc(oHandler.GetWorkspaceBudgetHistory).ServeHTTP(rr, req) assert.Equal(t, http.StatusUnauthorized, rr.Code) }) @@ -503,7 +503,7 @@ func TestGetOrganizationBudgetHistory(t *testing.T) { } oHandler.userHasAccess = mockUserHasAccess - mockDb.On("GetOrganizationBudgetHistory", orgUUID).Return(expectedBudgetHistory).Once() + mockDb.On("GetWorkspaceBudgetHistory", orgUUID).Return(expectedBudgetHistory).Once() rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -513,7 +513,7 @@ func TestGetOrganizationBudgetHistory(t *testing.T) { } rr := httptest.NewRecorder() - http.HandlerFunc(oHandler.GetOrganizationBudgetHistory).ServeHTTP(rr, req) + http.HandlerFunc(oHandler.GetWorkspaceBudgetHistory).ServeHTTP(rr, req) assert.Equal(t, http.StatusOK, rr.Code) @@ -527,16 +527,16 @@ func TestGetOrganizationBudgetHistory(t *testing.T) { }) } -func TestGetOrganizationBountiesCount(t *testing.T) { +func TestGetWorkspaceBountiesCount(t *testing.T) { ctx := context.WithValue(context.Background(), auth.ContextKey, "test-key") mockDb := mocks.NewDatabase(t) - oHandler := NewOrganizationHandler(mockDb) + oHandler := NewWorkspaceHandler(mockDb) t.Run("should return the count of organization bounties", func(t *testing.T) { orgUUID := "valid-uuid" expectedCount := int64(5) - mockDb.On("GetOrganizationBountiesCount", mock.AnythingOfType("*http.Request"), orgUUID).Return(expectedCount).Once() + mockDb.On("GetWorkspaceBountiesCount", mock.AnythingOfType("*http.Request"), orgUUID).Return(expectedCount).Once() rctx := chi.NewRouteContext() rctx.URLParams.Add("uuid", orgUUID) @@ -546,7 +546,7 @@ func TestGetOrganizationBountiesCount(t *testing.T) { } rr := httptest.NewRecorder() - http.HandlerFunc(oHandler.GetOrganizationBountiesCount).ServeHTTP(rr, req) + http.HandlerFunc(oHandler.GetWorkspaceBountiesCount).ServeHTTP(rr, req) assert.Equal(t, http.StatusOK, rr.Code) diff --git a/mocks/Database.go b/mocks/Database.go index 2332c98fd..c55befc41 100644 --- a/mocks/Database.go +++ b/mocks/Database.go @@ -449,12 +449,12 @@ func (_c *Database_BountiesPaidPercentage_Call) RunAndReturn(run func(db.Payment return _c } -// ChangeOrganizationDeleteStatus provides a mock function with given fields: org_uuid, status -func (_m *Database) ChangeOrganizationDeleteStatus(org_uuid string, status bool) db.Organization { +// ChangeWorkspaceDeleteStatus provides a mock function with given fields: org_uuid, status +func (_m *Database) ChangeWorkspaceDeleteStatus(org_uuid string, status bool) db.Organization { ret := _m.Called(org_uuid, status) if len(ret) == 0 { - panic("no return value specified for ChangeOrganizationDeleteStatus") + panic("no return value specified for ChangeWorkspaceDeleteStatus") } var r0 db.Organization @@ -467,31 +467,31 @@ func (_m *Database) ChangeOrganizationDeleteStatus(org_uuid string, status bool) return r0 } -// Database_ChangeOrganizationDeleteStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeOrganizationDeleteStatus' -type Database_ChangeOrganizationDeleteStatus_Call struct { +// Database_ChangeWorkspaceDeleteStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeWorkspaceDeleteStatus' +type Database_ChangeWorkspaceDeleteStatus_Call struct { *mock.Call } -// ChangeOrganizationDeleteStatus is a helper method to define mock.On call +// ChangeWorkspaceDeleteStatus is a helper method to define mock.On call // - org_uuid string // - status bool -func (_e *Database_Expecter) ChangeOrganizationDeleteStatus(org_uuid interface{}, status interface{}) *Database_ChangeOrganizationDeleteStatus_Call { - return &Database_ChangeOrganizationDeleteStatus_Call{Call: _e.mock.On("ChangeOrganizationDeleteStatus", org_uuid, status)} +func (_e *Database_Expecter) ChangeWorkspaceDeleteStatus(org_uuid interface{}, status interface{}) *Database_ChangeWorkspaceDeleteStatus_Call { + return &Database_ChangeWorkspaceDeleteStatus_Call{Call: _e.mock.On("ChangeWorkspaceDeleteStatus", org_uuid, status)} } -func (_c *Database_ChangeOrganizationDeleteStatus_Call) Run(run func(org_uuid string, status bool)) *Database_ChangeOrganizationDeleteStatus_Call { +func (_c *Database_ChangeWorkspaceDeleteStatus_Call) Run(run func(org_uuid string, status bool)) *Database_ChangeWorkspaceDeleteStatus_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string), args[1].(bool)) }) return _c } -func (_c *Database_ChangeOrganizationDeleteStatus_Call) Return(_a0 db.Organization) *Database_ChangeOrganizationDeleteStatus_Call { +func (_c *Database_ChangeWorkspaceDeleteStatus_Call) Return(_a0 db.Organization) *Database_ChangeWorkspaceDeleteStatus_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_ChangeOrganizationDeleteStatus_Call) RunAndReturn(run func(string, bool) db.Organization) *Database_ChangeOrganizationDeleteStatus_Call { +func (_c *Database_ChangeWorkspaceDeleteStatus_Call) RunAndReturn(run func(string, bool) db.Organization) *Database_ChangeWorkspaceDeleteStatus_Call { _c.Call.Return(run) return _c } @@ -927,26 +927,26 @@ func (_c *Database_CreateOrEditBounty_Call) RunAndReturn(run func(db.Bounty) (db return _c } -// CreateOrEditOrganization provides a mock function with given fields: m -func (_m *Database) CreateOrEditOrganization(m db.Organization) (db.Organization, error) { +// CreateOrEditPerson provides a mock function with given fields: m +func (_m *Database) CreateOrEditPerson(m db.Person) (db.Person, error) { ret := _m.Called(m) if len(ret) == 0 { - panic("no return value specified for CreateOrEditOrganization") + panic("no return value specified for CreateOrEditPerson") } - var r0 db.Organization + var r0 db.Person var r1 error - if rf, ok := ret.Get(0).(func(db.Organization) (db.Organization, error)); ok { + if rf, ok := ret.Get(0).(func(db.Person) (db.Person, error)); ok { return rf(m) } - if rf, ok := ret.Get(0).(func(db.Organization) db.Organization); ok { + if rf, ok := ret.Get(0).(func(db.Person) db.Person); ok { r0 = rf(m) } else { - r0 = ret.Get(0).(db.Organization) + r0 = ret.Get(0).(db.Person) } - if rf, ok := ret.Get(1).(func(db.Organization) error); ok { + if rf, ok := ret.Get(1).(func(db.Person) error); ok { r1 = rf(m) } else { r1 = ret.Error(1) @@ -955,54 +955,54 @@ func (_m *Database) CreateOrEditOrganization(m db.Organization) (db.Organization return r0, r1 } -// Database_CreateOrEditOrganization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditOrganization' -type Database_CreateOrEditOrganization_Call struct { +// Database_CreateOrEditPerson_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditPerson' +type Database_CreateOrEditPerson_Call struct { *mock.Call } -// CreateOrEditOrganization is a helper method to define mock.On call -// - m db.Organization -func (_e *Database_Expecter) CreateOrEditOrganization(m interface{}) *Database_CreateOrEditOrganization_Call { - return &Database_CreateOrEditOrganization_Call{Call: _e.mock.On("CreateOrEditOrganization", m)} +// CreateOrEditPerson is a helper method to define mock.On call +// - m db.Person +func (_e *Database_Expecter) CreateOrEditPerson(m interface{}) *Database_CreateOrEditPerson_Call { + return &Database_CreateOrEditPerson_Call{Call: _e.mock.On("CreateOrEditPerson", m)} } -func (_c *Database_CreateOrEditOrganization_Call) Run(run func(m db.Organization)) *Database_CreateOrEditOrganization_Call { +func (_c *Database_CreateOrEditPerson_Call) Run(run func(m db.Person)) *Database_CreateOrEditPerson_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.Organization)) + run(args[0].(db.Person)) }) return _c } -func (_c *Database_CreateOrEditOrganization_Call) Return(_a0 db.Organization, _a1 error) *Database_CreateOrEditOrganization_Call { +func (_c *Database_CreateOrEditPerson_Call) Return(_a0 db.Person, _a1 error) *Database_CreateOrEditPerson_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_CreateOrEditOrganization_Call) RunAndReturn(run func(db.Organization) (db.Organization, error)) *Database_CreateOrEditOrganization_Call { +func (_c *Database_CreateOrEditPerson_Call) RunAndReturn(run func(db.Person) (db.Person, error)) *Database_CreateOrEditPerson_Call { _c.Call.Return(run) return _c } -// CreateOrEditPerson provides a mock function with given fields: m -func (_m *Database) CreateOrEditPerson(m db.Person) (db.Person, error) { +// CreateOrEditTribe provides a mock function with given fields: m +func (_m *Database) CreateOrEditTribe(m db.Tribe) (db.Tribe, error) { ret := _m.Called(m) if len(ret) == 0 { - panic("no return value specified for CreateOrEditPerson") + panic("no return value specified for CreateOrEditTribe") } - var r0 db.Person + var r0 db.Tribe var r1 error - if rf, ok := ret.Get(0).(func(db.Person) (db.Person, error)); ok { + if rf, ok := ret.Get(0).(func(db.Tribe) (db.Tribe, error)); ok { return rf(m) } - if rf, ok := ret.Get(0).(func(db.Person) db.Person); ok { + if rf, ok := ret.Get(0).(func(db.Tribe) db.Tribe); ok { r0 = rf(m) } else { - r0 = ret.Get(0).(db.Person) + r0 = ret.Get(0).(db.Tribe) } - if rf, ok := ret.Get(1).(func(db.Person) error); ok { + if rf, ok := ret.Get(1).(func(db.Tribe) error); ok { r1 = rf(m) } else { r1 = ret.Error(1) @@ -1011,54 +1011,54 @@ func (_m *Database) CreateOrEditPerson(m db.Person) (db.Person, error) { return r0, r1 } -// Database_CreateOrEditPerson_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditPerson' -type Database_CreateOrEditPerson_Call struct { +// Database_CreateOrEditTribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditTribe' +type Database_CreateOrEditTribe_Call struct { *mock.Call } -// CreateOrEditPerson is a helper method to define mock.On call -// - m db.Person -func (_e *Database_Expecter) CreateOrEditPerson(m interface{}) *Database_CreateOrEditPerson_Call { - return &Database_CreateOrEditPerson_Call{Call: _e.mock.On("CreateOrEditPerson", m)} +// CreateOrEditTribe is a helper method to define mock.On call +// - m db.Tribe +func (_e *Database_Expecter) CreateOrEditTribe(m interface{}) *Database_CreateOrEditTribe_Call { + return &Database_CreateOrEditTribe_Call{Call: _e.mock.On("CreateOrEditTribe", m)} } -func (_c *Database_CreateOrEditPerson_Call) Run(run func(m db.Person)) *Database_CreateOrEditPerson_Call { +func (_c *Database_CreateOrEditTribe_Call) Run(run func(m db.Tribe)) *Database_CreateOrEditTribe_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.Person)) + run(args[0].(db.Tribe)) }) return _c } -func (_c *Database_CreateOrEditPerson_Call) Return(_a0 db.Person, _a1 error) *Database_CreateOrEditPerson_Call { +func (_c *Database_CreateOrEditTribe_Call) Return(_a0 db.Tribe, _a1 error) *Database_CreateOrEditTribe_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_CreateOrEditPerson_Call) RunAndReturn(run func(db.Person) (db.Person, error)) *Database_CreateOrEditPerson_Call { +func (_c *Database_CreateOrEditTribe_Call) RunAndReturn(run func(db.Tribe) (db.Tribe, error)) *Database_CreateOrEditTribe_Call { _c.Call.Return(run) return _c } -// CreateOrEditTribe provides a mock function with given fields: m -func (_m *Database) CreateOrEditTribe(m db.Tribe) (db.Tribe, error) { +// CreateOrEditWorkspace provides a mock function with given fields: m +func (_m *Database) CreateOrEditWorkspace(m db.Organization) (db.Organization, error) { ret := _m.Called(m) if len(ret) == 0 { - panic("no return value specified for CreateOrEditTribe") + panic("no return value specified for CreateOrEditWorkspace") } - var r0 db.Tribe + var r0 db.Organization var r1 error - if rf, ok := ret.Get(0).(func(db.Tribe) (db.Tribe, error)); ok { + if rf, ok := ret.Get(0).(func(db.Organization) (db.Organization, error)); ok { return rf(m) } - if rf, ok := ret.Get(0).(func(db.Tribe) db.Tribe); ok { + if rf, ok := ret.Get(0).(func(db.Organization) db.Organization); ok { r0 = rf(m) } else { - r0 = ret.Get(0).(db.Tribe) + r0 = ret.Get(0).(db.Organization) } - if rf, ok := ret.Get(1).(func(db.Tribe) error); ok { + if rf, ok := ret.Get(1).(func(db.Organization) error); ok { r1 = rf(m) } else { r1 = ret.Error(1) @@ -1067,182 +1067,182 @@ func (_m *Database) CreateOrEditTribe(m db.Tribe) (db.Tribe, error) { return r0, r1 } -// Database_CreateOrEditTribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditTribe' -type Database_CreateOrEditTribe_Call struct { +// Database_CreateOrEditWorkspace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditWorkspace' +type Database_CreateOrEditWorkspace_Call struct { *mock.Call } -// CreateOrEditTribe is a helper method to define mock.On call -// - m db.Tribe -func (_e *Database_Expecter) CreateOrEditTribe(m interface{}) *Database_CreateOrEditTribe_Call { - return &Database_CreateOrEditTribe_Call{Call: _e.mock.On("CreateOrEditTribe", m)} +// CreateOrEditWorkspace is a helper method to define mock.On call +// - m db.Organization +func (_e *Database_Expecter) CreateOrEditWorkspace(m interface{}) *Database_CreateOrEditWorkspace_Call { + return &Database_CreateOrEditWorkspace_Call{Call: _e.mock.On("CreateOrEditWorkspace", m)} } -func (_c *Database_CreateOrEditTribe_Call) Run(run func(m db.Tribe)) *Database_CreateOrEditTribe_Call { +func (_c *Database_CreateOrEditWorkspace_Call) Run(run func(m db.Organization)) *Database_CreateOrEditWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.Tribe)) + run(args[0].(db.Organization)) }) return _c } -func (_c *Database_CreateOrEditTribe_Call) Return(_a0 db.Tribe, _a1 error) *Database_CreateOrEditTribe_Call { +func (_c *Database_CreateOrEditWorkspace_Call) Return(_a0 db.Organization, _a1 error) *Database_CreateOrEditWorkspace_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_CreateOrEditTribe_Call) RunAndReturn(run func(db.Tribe) (db.Tribe, error)) *Database_CreateOrEditTribe_Call { +func (_c *Database_CreateOrEditWorkspace_Call) RunAndReturn(run func(db.Organization) (db.Organization, error)) *Database_CreateOrEditWorkspace_Call { _c.Call.Return(run) return _c } -// CreateOrganizationBudget provides a mock function with given fields: budget -func (_m *Database) CreateOrganizationBudget(budget db.BountyBudget) db.BountyBudget { - ret := _m.Called(budget) +// CreateUserRoles provides a mock function with given fields: roles, uuid, pubkey +func (_m *Database) CreateUserRoles(roles []db.UserRoles, uuid string, pubkey string) []db.UserRoles { + ret := _m.Called(roles, uuid, pubkey) if len(ret) == 0 { - panic("no return value specified for CreateOrganizationBudget") + panic("no return value specified for CreateUserRoles") } - var r0 db.BountyBudget - if rf, ok := ret.Get(0).(func(db.BountyBudget) db.BountyBudget); ok { - r0 = rf(budget) + var r0 []db.UserRoles + if rf, ok := ret.Get(0).(func([]db.UserRoles, string, string) []db.UserRoles); ok { + r0 = rf(roles, uuid, pubkey) } else { - r0 = ret.Get(0).(db.BountyBudget) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.UserRoles) + } } return r0 } -// Database_CreateOrganizationBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrganizationBudget' -type Database_CreateOrganizationBudget_Call struct { +// Database_CreateUserRoles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateUserRoles' +type Database_CreateUserRoles_Call struct { *mock.Call } -// CreateOrganizationBudget is a helper method to define mock.On call -// - budget db.BountyBudget -func (_e *Database_Expecter) CreateOrganizationBudget(budget interface{}) *Database_CreateOrganizationBudget_Call { - return &Database_CreateOrganizationBudget_Call{Call: _e.mock.On("CreateOrganizationBudget", budget)} +// CreateUserRoles is a helper method to define mock.On call +// - roles []db.UserRoles +// - uuid string +// - pubkey string +func (_e *Database_Expecter) CreateUserRoles(roles interface{}, uuid interface{}, pubkey interface{}) *Database_CreateUserRoles_Call { + return &Database_CreateUserRoles_Call{Call: _e.mock.On("CreateUserRoles", roles, uuid, pubkey)} } -func (_c *Database_CreateOrganizationBudget_Call) Run(run func(budget db.BountyBudget)) *Database_CreateOrganizationBudget_Call { +func (_c *Database_CreateUserRoles_Call) Run(run func(roles []db.UserRoles, uuid string, pubkey string)) *Database_CreateUserRoles_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.BountyBudget)) + run(args[0].([]db.UserRoles), args[1].(string), args[2].(string)) }) return _c } -func (_c *Database_CreateOrganizationBudget_Call) Return(_a0 db.BountyBudget) *Database_CreateOrganizationBudget_Call { +func (_c *Database_CreateUserRoles_Call) Return(_a0 []db.UserRoles) *Database_CreateUserRoles_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_CreateOrganizationBudget_Call) RunAndReturn(run func(db.BountyBudget) db.BountyBudget) *Database_CreateOrganizationBudget_Call { +func (_c *Database_CreateUserRoles_Call) RunAndReturn(run func([]db.UserRoles, string, string) []db.UserRoles) *Database_CreateUserRoles_Call { _c.Call.Return(run) return _c } -// CreateOrganizationUser provides a mock function with given fields: orgUser -func (_m *Database) CreateOrganizationUser(orgUser db.OrganizationUsers) db.OrganizationUsers { - ret := _m.Called(orgUser) +// CreateWorkspaceBudget provides a mock function with given fields: budget +func (_m *Database) CreateWorkspaceBudget(budget db.BountyBudget) db.BountyBudget { + ret := _m.Called(budget) if len(ret) == 0 { - panic("no return value specified for CreateOrganizationUser") + panic("no return value specified for CreateWorkspaceBudget") } - var r0 db.OrganizationUsers - if rf, ok := ret.Get(0).(func(db.OrganizationUsers) db.OrganizationUsers); ok { - r0 = rf(orgUser) + var r0 db.BountyBudget + if rf, ok := ret.Get(0).(func(db.BountyBudget) db.BountyBudget); ok { + r0 = rf(budget) } else { - r0 = ret.Get(0).(db.OrganizationUsers) + r0 = ret.Get(0).(db.BountyBudget) } return r0 } -// Database_CreateOrganizationUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrganizationUser' -type Database_CreateOrganizationUser_Call struct { +// Database_CreateWorkspaceBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWorkspaceBudget' +type Database_CreateWorkspaceBudget_Call struct { *mock.Call } -// CreateOrganizationUser is a helper method to define mock.On call -// - orgUser db.OrganizationUsers -func (_e *Database_Expecter) CreateOrganizationUser(orgUser interface{}) *Database_CreateOrganizationUser_Call { - return &Database_CreateOrganizationUser_Call{Call: _e.mock.On("CreateOrganizationUser", orgUser)} +// CreateWorkspaceBudget is a helper method to define mock.On call +// - budget db.BountyBudget +func (_e *Database_Expecter) CreateWorkspaceBudget(budget interface{}) *Database_CreateWorkspaceBudget_Call { + return &Database_CreateWorkspaceBudget_Call{Call: _e.mock.On("CreateWorkspaceBudget", budget)} } -func (_c *Database_CreateOrganizationUser_Call) Run(run func(orgUser db.OrganizationUsers)) *Database_CreateOrganizationUser_Call { +func (_c *Database_CreateWorkspaceBudget_Call) Run(run func(budget db.BountyBudget)) *Database_CreateWorkspaceBudget_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.OrganizationUsers)) + run(args[0].(db.BountyBudget)) }) return _c } -func (_c *Database_CreateOrganizationUser_Call) Return(_a0 db.OrganizationUsers) *Database_CreateOrganizationUser_Call { +func (_c *Database_CreateWorkspaceBudget_Call) Return(_a0 db.BountyBudget) *Database_CreateWorkspaceBudget_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_CreateOrganizationUser_Call) RunAndReturn(run func(db.OrganizationUsers) db.OrganizationUsers) *Database_CreateOrganizationUser_Call { +func (_c *Database_CreateWorkspaceBudget_Call) RunAndReturn(run func(db.BountyBudget) db.BountyBudget) *Database_CreateWorkspaceBudget_Call { _c.Call.Return(run) return _c } -// CreateUserRoles provides a mock function with given fields: roles, uuid, pubkey -func (_m *Database) CreateUserRoles(roles []db.UserRoles, uuid string, pubkey string) []db.UserRoles { - ret := _m.Called(roles, uuid, pubkey) +// CreateWorkspaceUser provides a mock function with given fields: orgUser +func (_m *Database) CreateWorkspaceUser(orgUser db.OrganizationUsers) db.OrganizationUsers { + ret := _m.Called(orgUser) if len(ret) == 0 { - panic("no return value specified for CreateUserRoles") + panic("no return value specified for CreateWorkspaceUser") } - var r0 []db.UserRoles - if rf, ok := ret.Get(0).(func([]db.UserRoles, string, string) []db.UserRoles); ok { - r0 = rf(roles, uuid, pubkey) + var r0 db.OrganizationUsers + if rf, ok := ret.Get(0).(func(db.OrganizationUsers) db.OrganizationUsers); ok { + r0 = rf(orgUser) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.UserRoles) - } + r0 = ret.Get(0).(db.OrganizationUsers) } return r0 } -// Database_CreateUserRoles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateUserRoles' -type Database_CreateUserRoles_Call struct { +// Database_CreateWorkspaceUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWorkspaceUser' +type Database_CreateWorkspaceUser_Call struct { *mock.Call } -// CreateUserRoles is a helper method to define mock.On call -// - roles []db.UserRoles -// - uuid string -// - pubkey string -func (_e *Database_Expecter) CreateUserRoles(roles interface{}, uuid interface{}, pubkey interface{}) *Database_CreateUserRoles_Call { - return &Database_CreateUserRoles_Call{Call: _e.mock.On("CreateUserRoles", roles, uuid, pubkey)} +// CreateWorkspaceUser is a helper method to define mock.On call +// - orgUser db.OrganizationUsers +func (_e *Database_Expecter) CreateWorkspaceUser(orgUser interface{}) *Database_CreateWorkspaceUser_Call { + return &Database_CreateWorkspaceUser_Call{Call: _e.mock.On("CreateWorkspaceUser", orgUser)} } -func (_c *Database_CreateUserRoles_Call) Run(run func(roles []db.UserRoles, uuid string, pubkey string)) *Database_CreateUserRoles_Call { +func (_c *Database_CreateWorkspaceUser_Call) Run(run func(orgUser db.OrganizationUsers)) *Database_CreateWorkspaceUser_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].([]db.UserRoles), args[1].(string), args[2].(string)) + run(args[0].(db.OrganizationUsers)) }) return _c } -func (_c *Database_CreateUserRoles_Call) Return(_a0 []db.UserRoles) *Database_CreateUserRoles_Call { +func (_c *Database_CreateWorkspaceUser_Call) Return(_a0 db.OrganizationUsers) *Database_CreateWorkspaceUser_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_CreateUserRoles_Call) RunAndReturn(run func([]db.UserRoles, string, string) []db.UserRoles) *Database_CreateUserRoles_Call { +func (_c *Database_CreateWorkspaceUser_Call) RunAndReturn(run func(db.OrganizationUsers) db.OrganizationUsers) *Database_CreateWorkspaceUser_Call { _c.Call.Return(run) return _c } -// DeleteAllUsersFromOrganization provides a mock function with given fields: uuid -func (_m *Database) DeleteAllUsersFromOrganization(uuid string) error { +// DeleteAllUsersFromWorkspace provides a mock function with given fields: uuid +func (_m *Database) DeleteAllUsersFromWorkspace(uuid string) error { ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for DeleteAllUsersFromOrganization") + panic("no return value specified for DeleteAllUsersFromWorkspace") } var r0 error @@ -1255,30 +1255,30 @@ func (_m *Database) DeleteAllUsersFromOrganization(uuid string) error { return r0 } -// Database_DeleteAllUsersFromOrganization_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteAllUsersFromOrganization' -type Database_DeleteAllUsersFromOrganization_Call struct { +// Database_DeleteAllUsersFromWorkspace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteAllUsersFromWorkspace' +type Database_DeleteAllUsersFromWorkspace_Call struct { *mock.Call } -// DeleteAllUsersFromOrganization is a helper method to define mock.On call +// DeleteAllUsersFromWorkspace is a helper method to define mock.On call // - uuid string -func (_e *Database_Expecter) DeleteAllUsersFromOrganization(uuid interface{}) *Database_DeleteAllUsersFromOrganization_Call { - return &Database_DeleteAllUsersFromOrganization_Call{Call: _e.mock.On("DeleteAllUsersFromOrganization", uuid)} +func (_e *Database_Expecter) DeleteAllUsersFromWorkspace(uuid interface{}) *Database_DeleteAllUsersFromWorkspace_Call { + return &Database_DeleteAllUsersFromWorkspace_Call{Call: _e.mock.On("DeleteAllUsersFromWorkspace", uuid)} } -func (_c *Database_DeleteAllUsersFromOrganization_Call) Run(run func(uuid string)) *Database_DeleteAllUsersFromOrganization_Call { +func (_c *Database_DeleteAllUsersFromWorkspace_Call) Run(run func(uuid string)) *Database_DeleteAllUsersFromWorkspace_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_DeleteAllUsersFromOrganization_Call) Return(_a0 error) *Database_DeleteAllUsersFromOrganization_Call { +func (_c *Database_DeleteAllUsersFromWorkspace_Call) Return(_a0 error) *Database_DeleteAllUsersFromWorkspace_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_DeleteAllUsersFromOrganization_Call) RunAndReturn(run func(string) error) *Database_DeleteAllUsersFromOrganization_Call { +func (_c *Database_DeleteAllUsersFromWorkspace_Call) RunAndReturn(run func(string) error) *Database_DeleteAllUsersFromWorkspace_Call { _c.Call.Return(run) return _c } @@ -1340,95 +1340,95 @@ func (_c *Database_DeleteBounty_Call) RunAndReturn(run func(string, string) (db. return _c } -// DeleteOrganizationUser provides a mock function with given fields: orgUser, org -func (_m *Database) DeleteOrganizationUser(orgUser db.OrganizationUsersData, org string) db.OrganizationUsersData { - ret := _m.Called(orgUser, org) +// DeleteUserInvoiceData provides a mock function with given fields: payment_request +func (_m *Database) DeleteUserInvoiceData(payment_request string) db.UserInvoiceData { + ret := _m.Called(payment_request) if len(ret) == 0 { - panic("no return value specified for DeleteOrganizationUser") + panic("no return value specified for DeleteUserInvoiceData") } - var r0 db.OrganizationUsersData - if rf, ok := ret.Get(0).(func(db.OrganizationUsersData, string) db.OrganizationUsersData); ok { - r0 = rf(orgUser, org) + var r0 db.UserInvoiceData + if rf, ok := ret.Get(0).(func(string) db.UserInvoiceData); ok { + r0 = rf(payment_request) } else { - r0 = ret.Get(0).(db.OrganizationUsersData) + r0 = ret.Get(0).(db.UserInvoiceData) } return r0 } -// Database_DeleteOrganizationUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteOrganizationUser' -type Database_DeleteOrganizationUser_Call struct { +// Database_DeleteUserInvoiceData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteUserInvoiceData' +type Database_DeleteUserInvoiceData_Call struct { *mock.Call } -// DeleteOrganizationUser is a helper method to define mock.On call -// - orgUser db.OrganizationUsersData -// - org string -func (_e *Database_Expecter) DeleteOrganizationUser(orgUser interface{}, org interface{}) *Database_DeleteOrganizationUser_Call { - return &Database_DeleteOrganizationUser_Call{Call: _e.mock.On("DeleteOrganizationUser", orgUser, org)} +// DeleteUserInvoiceData is a helper method to define mock.On call +// - payment_request string +func (_e *Database_Expecter) DeleteUserInvoiceData(payment_request interface{}) *Database_DeleteUserInvoiceData_Call { + return &Database_DeleteUserInvoiceData_Call{Call: _e.mock.On("DeleteUserInvoiceData", payment_request)} } -func (_c *Database_DeleteOrganizationUser_Call) Run(run func(orgUser db.OrganizationUsersData, org string)) *Database_DeleteOrganizationUser_Call { +func (_c *Database_DeleteUserInvoiceData_Call) Run(run func(payment_request string)) *Database_DeleteUserInvoiceData_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.OrganizationUsersData), args[1].(string)) + run(args[0].(string)) }) return _c } -func (_c *Database_DeleteOrganizationUser_Call) Return(_a0 db.OrganizationUsersData) *Database_DeleteOrganizationUser_Call { +func (_c *Database_DeleteUserInvoiceData_Call) Return(_a0 db.UserInvoiceData) *Database_DeleteUserInvoiceData_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_DeleteOrganizationUser_Call) RunAndReturn(run func(db.OrganizationUsersData, string) db.OrganizationUsersData) *Database_DeleteOrganizationUser_Call { +func (_c *Database_DeleteUserInvoiceData_Call) RunAndReturn(run func(string) db.UserInvoiceData) *Database_DeleteUserInvoiceData_Call { _c.Call.Return(run) return _c } -// DeleteUserInvoiceData provides a mock function with given fields: payment_request -func (_m *Database) DeleteUserInvoiceData(payment_request string) db.UserInvoiceData { - ret := _m.Called(payment_request) +// DeleteWorkspaceUser provides a mock function with given fields: orgUser, org +func (_m *Database) DeleteWorkspaceUser(orgUser db.OrganizationUsersData, org string) db.OrganizationUsersData { + ret := _m.Called(orgUser, org) if len(ret) == 0 { - panic("no return value specified for DeleteUserInvoiceData") + panic("no return value specified for DeleteWorkspaceUser") } - var r0 db.UserInvoiceData - if rf, ok := ret.Get(0).(func(string) db.UserInvoiceData); ok { - r0 = rf(payment_request) + var r0 db.OrganizationUsersData + if rf, ok := ret.Get(0).(func(db.OrganizationUsersData, string) db.OrganizationUsersData); ok { + r0 = rf(orgUser, org) } else { - r0 = ret.Get(0).(db.UserInvoiceData) + r0 = ret.Get(0).(db.OrganizationUsersData) } return r0 } -// Database_DeleteUserInvoiceData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteUserInvoiceData' -type Database_DeleteUserInvoiceData_Call struct { +// Database_DeleteWorkspaceUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteWorkspaceUser' +type Database_DeleteWorkspaceUser_Call struct { *mock.Call } -// DeleteUserInvoiceData is a helper method to define mock.On call -// - payment_request string -func (_e *Database_Expecter) DeleteUserInvoiceData(payment_request interface{}) *Database_DeleteUserInvoiceData_Call { - return &Database_DeleteUserInvoiceData_Call{Call: _e.mock.On("DeleteUserInvoiceData", payment_request)} +// DeleteWorkspaceUser is a helper method to define mock.On call +// - orgUser db.OrganizationUsersData +// - org string +func (_e *Database_Expecter) DeleteWorkspaceUser(orgUser interface{}, org interface{}) *Database_DeleteWorkspaceUser_Call { + return &Database_DeleteWorkspaceUser_Call{Call: _e.mock.On("DeleteWorkspaceUser", orgUser, org)} } -func (_c *Database_DeleteUserInvoiceData_Call) Run(run func(payment_request string)) *Database_DeleteUserInvoiceData_Call { +func (_c *Database_DeleteWorkspaceUser_Call) Run(run func(orgUser db.OrganizationUsersData, org string)) *Database_DeleteWorkspaceUser_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(db.OrganizationUsersData), args[1].(string)) }) return _c } -func (_c *Database_DeleteUserInvoiceData_Call) Return(_a0 db.UserInvoiceData) *Database_DeleteUserInvoiceData_Call { +func (_c *Database_DeleteWorkspaceUser_Call) Return(_a0 db.OrganizationUsersData) *Database_DeleteWorkspaceUser_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_DeleteUserInvoiceData_Call) RunAndReturn(run func(string) db.UserInvoiceData) *Database_DeleteUserInvoiceData_Call { +func (_c *Database_DeleteWorkspaceUser_Call) RunAndReturn(run func(db.OrganizationUsersData, string) db.OrganizationUsersData) *Database_DeleteWorkspaceUser_Call { _c.Call.Return(run) return _c } @@ -3114,12 +3114,12 @@ func (_c *Database_GetNextBountyByCreated_Call) RunAndReturn(run func(*http.Requ return _c } -// GetNextOrganizationBountyByCreated provides a mock function with given fields: r -func (_m *Database) GetNextOrganizationBountyByCreated(r *http.Request) (uint, error) { +// GetNextWorkspaceBountyByCreated provides a mock function with given fields: r +func (_m *Database) GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error) { ret := _m.Called(r) if len(ret) == 0 { - panic("no return value specified for GetNextOrganizationBountyByCreated") + panic("no return value specified for GetNextWorkspaceBountyByCreated") } var r0 uint @@ -3142,30 +3142,30 @@ func (_m *Database) GetNextOrganizationBountyByCreated(r *http.Request) (uint, e return r0, r1 } -// Database_GetNextOrganizationBountyByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNextOrganizationBountyByCreated' -type Database_GetNextOrganizationBountyByCreated_Call struct { +// Database_GetNextWorkspaceBountyByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNextWorkspaceBountyByCreated' +type Database_GetNextWorkspaceBountyByCreated_Call struct { *mock.Call } -// GetNextOrganizationBountyByCreated is a helper method to define mock.On call +// GetNextWorkspaceBountyByCreated is a helper method to define mock.On call // - r *http.Request -func (_e *Database_Expecter) GetNextOrganizationBountyByCreated(r interface{}) *Database_GetNextOrganizationBountyByCreated_Call { - return &Database_GetNextOrganizationBountyByCreated_Call{Call: _e.mock.On("GetNextOrganizationBountyByCreated", r)} +func (_e *Database_Expecter) GetNextWorkspaceBountyByCreated(r interface{}) *Database_GetNextWorkspaceBountyByCreated_Call { + return &Database_GetNextWorkspaceBountyByCreated_Call{Call: _e.mock.On("GetNextWorkspaceBountyByCreated", r)} } -func (_c *Database_GetNextOrganizationBountyByCreated_Call) Run(run func(r *http.Request)) *Database_GetNextOrganizationBountyByCreated_Call { +func (_c *Database_GetNextWorkspaceBountyByCreated_Call) Run(run func(r *http.Request)) *Database_GetNextWorkspaceBountyByCreated_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(*http.Request)) }) return _c } -func (_c *Database_GetNextOrganizationBountyByCreated_Call) Return(_a0 uint, _a1 error) *Database_GetNextOrganizationBountyByCreated_Call { +func (_c *Database_GetNextWorkspaceBountyByCreated_Call) Return(_a0 uint, _a1 error) *Database_GetNextWorkspaceBountyByCreated_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetNextOrganizationBountyByCreated_Call) RunAndReturn(run func(*http.Request) (uint, error)) *Database_GetNextOrganizationBountyByCreated_Call { +func (_c *Database_GetNextWorkspaceBountyByCreated_Call) RunAndReturn(run func(*http.Request) (uint, error)) *Database_GetNextWorkspaceBountyByCreated_Call { _c.Call.Return(run) return _c } @@ -3226,825 +3226,831 @@ func (_c *Database_GetOpenGithubIssues_Call) RunAndReturn(run func(*http.Request return _c } -// GetOrganizationBounties provides a mock function with given fields: r, org_uuid -func (_m *Database) GetOrganizationBounties(r *http.Request, org_uuid string) []db.Bounty { - ret := _m.Called(r, org_uuid) +// GetPaymentHistory provides a mock function with given fields: org_uuid, r +func (_m *Database) GetPaymentHistory(org_uuid string, r *http.Request) []db.PaymentHistory { + ret := _m.Called(org_uuid, r) if len(ret) == 0 { - panic("no return value specified for GetOrganizationBounties") + panic("no return value specified for GetPaymentHistory") } - var r0 []db.Bounty - if rf, ok := ret.Get(0).(func(*http.Request, string) []db.Bounty); ok { - r0 = rf(r, org_uuid) + var r0 []db.PaymentHistory + if rf, ok := ret.Get(0).(func(string, *http.Request) []db.PaymentHistory); ok { + r0 = rf(org_uuid, r) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Bounty) + r0 = ret.Get(0).([]db.PaymentHistory) } } return r0 } -// Database_GetOrganizationBounties_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationBounties' -type Database_GetOrganizationBounties_Call struct { +// Database_GetPaymentHistory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPaymentHistory' +type Database_GetPaymentHistory_Call struct { *mock.Call } -// GetOrganizationBounties is a helper method to define mock.On call -// - r *http.Request +// GetPaymentHistory is a helper method to define mock.On call // - org_uuid string -func (_e *Database_Expecter) GetOrganizationBounties(r interface{}, org_uuid interface{}) *Database_GetOrganizationBounties_Call { - return &Database_GetOrganizationBounties_Call{Call: _e.mock.On("GetOrganizationBounties", r, org_uuid)} +// - r *http.Request +func (_e *Database_Expecter) GetPaymentHistory(org_uuid interface{}, r interface{}) *Database_GetPaymentHistory_Call { + return &Database_GetPaymentHistory_Call{Call: _e.mock.On("GetPaymentHistory", org_uuid, r)} } -func (_c *Database_GetOrganizationBounties_Call) Run(run func(r *http.Request, org_uuid string)) *Database_GetOrganizationBounties_Call { +func (_c *Database_GetPaymentHistory_Call) Run(run func(org_uuid string, r *http.Request)) *Database_GetPaymentHistory_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request), args[1].(string)) + run(args[0].(string), args[1].(*http.Request)) }) return _c } -func (_c *Database_GetOrganizationBounties_Call) Return(_a0 []db.Bounty) *Database_GetOrganizationBounties_Call { +func (_c *Database_GetPaymentHistory_Call) Return(_a0 []db.PaymentHistory) *Database_GetPaymentHistory_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationBounties_Call) RunAndReturn(run func(*http.Request, string) []db.Bounty) *Database_GetOrganizationBounties_Call { +func (_c *Database_GetPaymentHistory_Call) RunAndReturn(run func(string, *http.Request) []db.PaymentHistory) *Database_GetPaymentHistory_Call { _c.Call.Return(run) return _c } -// GetOrganizationBountiesCount provides a mock function with given fields: r, org_uuid -func (_m *Database) GetOrganizationBountiesCount(r *http.Request, org_uuid string) int64 { - ret := _m.Called(r, org_uuid) +// GetPaymentHistoryByCreated provides a mock function with given fields: created, org_uuid +func (_m *Database) GetPaymentHistoryByCreated(created *time.Time, org_uuid string) db.PaymentHistory { + ret := _m.Called(created, org_uuid) if len(ret) == 0 { - panic("no return value specified for GetOrganizationBountiesCount") + panic("no return value specified for GetPaymentHistoryByCreated") } - var r0 int64 - if rf, ok := ret.Get(0).(func(*http.Request, string) int64); ok { - r0 = rf(r, org_uuid) + var r0 db.PaymentHistory + if rf, ok := ret.Get(0).(func(*time.Time, string) db.PaymentHistory); ok { + r0 = rf(created, org_uuid) } else { - r0 = ret.Get(0).(int64) + r0 = ret.Get(0).(db.PaymentHistory) } return r0 } -// Database_GetOrganizationBountiesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationBountiesCount' -type Database_GetOrganizationBountiesCount_Call struct { +// Database_GetPaymentHistoryByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPaymentHistoryByCreated' +type Database_GetPaymentHistoryByCreated_Call struct { *mock.Call } -// GetOrganizationBountiesCount is a helper method to define mock.On call -// - r *http.Request +// GetPaymentHistoryByCreated is a helper method to define mock.On call +// - created *time.Time // - org_uuid string -func (_e *Database_Expecter) GetOrganizationBountiesCount(r interface{}, org_uuid interface{}) *Database_GetOrganizationBountiesCount_Call { - return &Database_GetOrganizationBountiesCount_Call{Call: _e.mock.On("GetOrganizationBountiesCount", r, org_uuid)} +func (_e *Database_Expecter) GetPaymentHistoryByCreated(created interface{}, org_uuid interface{}) *Database_GetPaymentHistoryByCreated_Call { + return &Database_GetPaymentHistoryByCreated_Call{Call: _e.mock.On("GetPaymentHistoryByCreated", created, org_uuid)} } -func (_c *Database_GetOrganizationBountiesCount_Call) Run(run func(r *http.Request, org_uuid string)) *Database_GetOrganizationBountiesCount_Call { +func (_c *Database_GetPaymentHistoryByCreated_Call) Run(run func(created *time.Time, org_uuid string)) *Database_GetPaymentHistoryByCreated_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request), args[1].(string)) + run(args[0].(*time.Time), args[1].(string)) }) return _c } -func (_c *Database_GetOrganizationBountiesCount_Call) Return(_a0 int64) *Database_GetOrganizationBountiesCount_Call { +func (_c *Database_GetPaymentHistoryByCreated_Call) Return(_a0 db.PaymentHistory) *Database_GetPaymentHistoryByCreated_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationBountiesCount_Call) RunAndReturn(run func(*http.Request, string) int64) *Database_GetOrganizationBountiesCount_Call { +func (_c *Database_GetPaymentHistoryByCreated_Call) RunAndReturn(run func(*time.Time, string) db.PaymentHistory) *Database_GetPaymentHistoryByCreated_Call { _c.Call.Return(run) return _c } -// GetOrganizationBountyCount provides a mock function with given fields: uuid -func (_m *Database) GetOrganizationBountyCount(uuid string) int64 { - ret := _m.Called(uuid) +// GetPeopleBySearch provides a mock function with given fields: r +func (_m *Database) GetPeopleBySearch(r *http.Request) []db.Person { + ret := _m.Called(r) if len(ret) == 0 { - panic("no return value specified for GetOrganizationBountyCount") + panic("no return value specified for GetPeopleBySearch") } - var r0 int64 - if rf, ok := ret.Get(0).(func(string) int64); ok { - r0 = rf(uuid) + var r0 []db.Person + if rf, ok := ret.Get(0).(func(*http.Request) []db.Person); ok { + r0 = rf(r) } else { - r0 = ret.Get(0).(int64) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.Person) + } } return r0 } -// Database_GetOrganizationBountyCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationBountyCount' -type Database_GetOrganizationBountyCount_Call struct { +// Database_GetPeopleBySearch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPeopleBySearch' +type Database_GetPeopleBySearch_Call struct { *mock.Call } -// GetOrganizationBountyCount is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) GetOrganizationBountyCount(uuid interface{}) *Database_GetOrganizationBountyCount_Call { - return &Database_GetOrganizationBountyCount_Call{Call: _e.mock.On("GetOrganizationBountyCount", uuid)} +// GetPeopleBySearch is a helper method to define mock.On call +// - r *http.Request +func (_e *Database_Expecter) GetPeopleBySearch(r interface{}) *Database_GetPeopleBySearch_Call { + return &Database_GetPeopleBySearch_Call{Call: _e.mock.On("GetPeopleBySearch", r)} } -func (_c *Database_GetOrganizationBountyCount_Call) Run(run func(uuid string)) *Database_GetOrganizationBountyCount_Call { +func (_c *Database_GetPeopleBySearch_Call) Run(run func(r *http.Request)) *Database_GetPeopleBySearch_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(*http.Request)) }) return _c } -func (_c *Database_GetOrganizationBountyCount_Call) Return(_a0 int64) *Database_GetOrganizationBountyCount_Call { +func (_c *Database_GetPeopleBySearch_Call) Return(_a0 []db.Person) *Database_GetPeopleBySearch_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationBountyCount_Call) RunAndReturn(run func(string) int64) *Database_GetOrganizationBountyCount_Call { +func (_c *Database_GetPeopleBySearch_Call) RunAndReturn(run func(*http.Request) []db.Person) *Database_GetPeopleBySearch_Call { _c.Call.Return(run) return _c } -// GetOrganizationBudget provides a mock function with given fields: org_uuid -func (_m *Database) GetOrganizationBudget(org_uuid string) db.BountyBudget { - ret := _m.Called(org_uuid) +// GetPeopleListShort provides a mock function with given fields: count +func (_m *Database) GetPeopleListShort(count uint32) *[]db.PersonInShort { + ret := _m.Called(count) if len(ret) == 0 { - panic("no return value specified for GetOrganizationBudget") + panic("no return value specified for GetPeopleListShort") } - var r0 db.BountyBudget - if rf, ok := ret.Get(0).(func(string) db.BountyBudget); ok { - r0 = rf(org_uuid) + var r0 *[]db.PersonInShort + if rf, ok := ret.Get(0).(func(uint32) *[]db.PersonInShort); ok { + r0 = rf(count) } else { - r0 = ret.Get(0).(db.BountyBudget) + if ret.Get(0) != nil { + r0 = ret.Get(0).(*[]db.PersonInShort) + } } return r0 } -// Database_GetOrganizationBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationBudget' -type Database_GetOrganizationBudget_Call struct { +// Database_GetPeopleListShort_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPeopleListShort' +type Database_GetPeopleListShort_Call struct { *mock.Call } -// GetOrganizationBudget is a helper method to define mock.On call -// - org_uuid string -func (_e *Database_Expecter) GetOrganizationBudget(org_uuid interface{}) *Database_GetOrganizationBudget_Call { - return &Database_GetOrganizationBudget_Call{Call: _e.mock.On("GetOrganizationBudget", org_uuid)} +// GetPeopleListShort is a helper method to define mock.On call +// - count uint32 +func (_e *Database_Expecter) GetPeopleListShort(count interface{}) *Database_GetPeopleListShort_Call { + return &Database_GetPeopleListShort_Call{Call: _e.mock.On("GetPeopleListShort", count)} } -func (_c *Database_GetOrganizationBudget_Call) Run(run func(org_uuid string)) *Database_GetOrganizationBudget_Call { +func (_c *Database_GetPeopleListShort_Call) Run(run func(count uint32)) *Database_GetPeopleListShort_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(uint32)) }) return _c } -func (_c *Database_GetOrganizationBudget_Call) Return(_a0 db.BountyBudget) *Database_GetOrganizationBudget_Call { +func (_c *Database_GetPeopleListShort_Call) Return(_a0 *[]db.PersonInShort) *Database_GetPeopleListShort_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationBudget_Call) RunAndReturn(run func(string) db.BountyBudget) *Database_GetOrganizationBudget_Call { +func (_c *Database_GetPeopleListShort_Call) RunAndReturn(run func(uint32) *[]db.PersonInShort) *Database_GetPeopleListShort_Call { _c.Call.Return(run) return _c } -// GetOrganizationBudgetHistory provides a mock function with given fields: org_uuid -func (_m *Database) GetOrganizationBudgetHistory(org_uuid string) []db.BudgetHistoryData { - ret := _m.Called(org_uuid) +// GetPerson provides a mock function with given fields: id +func (_m *Database) GetPerson(id uint) db.Person { + ret := _m.Called(id) if len(ret) == 0 { - panic("no return value specified for GetOrganizationBudgetHistory") + panic("no return value specified for GetPerson") } - var r0 []db.BudgetHistoryData - if rf, ok := ret.Get(0).(func(string) []db.BudgetHistoryData); ok { - r0 = rf(org_uuid) + var r0 db.Person + if rf, ok := ret.Get(0).(func(uint) db.Person); ok { + r0 = rf(id) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.BudgetHistoryData) - } + r0 = ret.Get(0).(db.Person) } return r0 } -// Database_GetOrganizationBudgetHistory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationBudgetHistory' -type Database_GetOrganizationBudgetHistory_Call struct { +// Database_GetPerson_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPerson' +type Database_GetPerson_Call struct { *mock.Call } -// GetOrganizationBudgetHistory is a helper method to define mock.On call -// - org_uuid string -func (_e *Database_Expecter) GetOrganizationBudgetHistory(org_uuid interface{}) *Database_GetOrganizationBudgetHistory_Call { - return &Database_GetOrganizationBudgetHistory_Call{Call: _e.mock.On("GetOrganizationBudgetHistory", org_uuid)} +// GetPerson is a helper method to define mock.On call +// - id uint +func (_e *Database_Expecter) GetPerson(id interface{}) *Database_GetPerson_Call { + return &Database_GetPerson_Call{Call: _e.mock.On("GetPerson", id)} } -func (_c *Database_GetOrganizationBudgetHistory_Call) Run(run func(org_uuid string)) *Database_GetOrganizationBudgetHistory_Call { +func (_c *Database_GetPerson_Call) Run(run func(id uint)) *Database_GetPerson_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(uint)) }) return _c } -func (_c *Database_GetOrganizationBudgetHistory_Call) Return(_a0 []db.BudgetHistoryData) *Database_GetOrganizationBudgetHistory_Call { +func (_c *Database_GetPerson_Call) Return(_a0 db.Person) *Database_GetPerson_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationBudgetHistory_Call) RunAndReturn(run func(string) []db.BudgetHistoryData) *Database_GetOrganizationBudgetHistory_Call { +func (_c *Database_GetPerson_Call) RunAndReturn(run func(uint) db.Person) *Database_GetPerson_Call { _c.Call.Return(run) return _c } -// GetOrganizationByName provides a mock function with given fields: name -func (_m *Database) GetOrganizationByName(name string) db.Organization { - ret := _m.Called(name) +// GetPersonByGithubName provides a mock function with given fields: github_name +func (_m *Database) GetPersonByGithubName(github_name string) db.Person { + ret := _m.Called(github_name) if len(ret) == 0 { - panic("no return value specified for GetOrganizationByName") + panic("no return value specified for GetPersonByGithubName") } - var r0 db.Organization - if rf, ok := ret.Get(0).(func(string) db.Organization); ok { - r0 = rf(name) + var r0 db.Person + if rf, ok := ret.Get(0).(func(string) db.Person); ok { + r0 = rf(github_name) } else { - r0 = ret.Get(0).(db.Organization) + r0 = ret.Get(0).(db.Person) } return r0 } -// Database_GetOrganizationByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationByName' -type Database_GetOrganizationByName_Call struct { +// Database_GetPersonByGithubName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByGithubName' +type Database_GetPersonByGithubName_Call struct { *mock.Call } -// GetOrganizationByName is a helper method to define mock.On call -// - name string -func (_e *Database_Expecter) GetOrganizationByName(name interface{}) *Database_GetOrganizationByName_Call { - return &Database_GetOrganizationByName_Call{Call: _e.mock.On("GetOrganizationByName", name)} +// GetPersonByGithubName is a helper method to define mock.On call +// - github_name string +func (_e *Database_Expecter) GetPersonByGithubName(github_name interface{}) *Database_GetPersonByGithubName_Call { + return &Database_GetPersonByGithubName_Call{Call: _e.mock.On("GetPersonByGithubName", github_name)} } -func (_c *Database_GetOrganizationByName_Call) Run(run func(name string)) *Database_GetOrganizationByName_Call { +func (_c *Database_GetPersonByGithubName_Call) Run(run func(github_name string)) *Database_GetPersonByGithubName_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizationByName_Call) Return(_a0 db.Organization) *Database_GetOrganizationByName_Call { +func (_c *Database_GetPersonByGithubName_Call) Return(_a0 db.Person) *Database_GetPersonByGithubName_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationByName_Call) RunAndReturn(run func(string) db.Organization) *Database_GetOrganizationByName_Call { +func (_c *Database_GetPersonByGithubName_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByGithubName_Call { _c.Call.Return(run) return _c } -// GetOrganizationByUuid provides a mock function with given fields: uuid -func (_m *Database) GetOrganizationByUuid(uuid string) db.Organization { - ret := _m.Called(uuid) +// GetPersonByPubkey provides a mock function with given fields: pubkey +func (_m *Database) GetPersonByPubkey(pubkey string) db.Person { + ret := _m.Called(pubkey) if len(ret) == 0 { - panic("no return value specified for GetOrganizationByUuid") + panic("no return value specified for GetPersonByPubkey") } - var r0 db.Organization - if rf, ok := ret.Get(0).(func(string) db.Organization); ok { - r0 = rf(uuid) + var r0 db.Person + if rf, ok := ret.Get(0).(func(string) db.Person); ok { + r0 = rf(pubkey) } else { - r0 = ret.Get(0).(db.Organization) + r0 = ret.Get(0).(db.Person) } return r0 } -// Database_GetOrganizationByUuid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationByUuid' -type Database_GetOrganizationByUuid_Call struct { +// Database_GetPersonByPubkey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByPubkey' +type Database_GetPersonByPubkey_Call struct { *mock.Call } -// GetOrganizationByUuid is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) GetOrganizationByUuid(uuid interface{}) *Database_GetOrganizationByUuid_Call { - return &Database_GetOrganizationByUuid_Call{Call: _e.mock.On("GetOrganizationByUuid", uuid)} +// GetPersonByPubkey is a helper method to define mock.On call +// - pubkey string +func (_e *Database_Expecter) GetPersonByPubkey(pubkey interface{}) *Database_GetPersonByPubkey_Call { + return &Database_GetPersonByPubkey_Call{Call: _e.mock.On("GetPersonByPubkey", pubkey)} } -func (_c *Database_GetOrganizationByUuid_Call) Run(run func(uuid string)) *Database_GetOrganizationByUuid_Call { +func (_c *Database_GetPersonByPubkey_Call) Run(run func(pubkey string)) *Database_GetPersonByPubkey_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizationByUuid_Call) Return(_a0 db.Organization) *Database_GetOrganizationByUuid_Call { +func (_c *Database_GetPersonByPubkey_Call) Return(_a0 db.Person) *Database_GetPersonByPubkey_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationByUuid_Call) RunAndReturn(run func(string) db.Organization) *Database_GetOrganizationByUuid_Call { +func (_c *Database_GetPersonByPubkey_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByPubkey_Call { _c.Call.Return(run) return _c } -// GetOrganizationInvoices provides a mock function with given fields: org_uuid -func (_m *Database) GetOrganizationInvoices(org_uuid string) []db.InvoiceList { - ret := _m.Called(org_uuid) +// GetPersonByUniqueName provides a mock function with given fields: un +func (_m *Database) GetPersonByUniqueName(un string) db.Person { + ret := _m.Called(un) if len(ret) == 0 { - panic("no return value specified for GetOrganizationInvoices") + panic("no return value specified for GetPersonByUniqueName") } - var r0 []db.InvoiceList - if rf, ok := ret.Get(0).(func(string) []db.InvoiceList); ok { - r0 = rf(org_uuid) + var r0 db.Person + if rf, ok := ret.Get(0).(func(string) db.Person); ok { + r0 = rf(un) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.InvoiceList) - } + r0 = ret.Get(0).(db.Person) } return r0 } -// Database_GetOrganizationInvoices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationInvoices' -type Database_GetOrganizationInvoices_Call struct { +// Database_GetPersonByUniqueName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByUniqueName' +type Database_GetPersonByUniqueName_Call struct { *mock.Call } -// GetOrganizationInvoices is a helper method to define mock.On call -// - org_uuid string -func (_e *Database_Expecter) GetOrganizationInvoices(org_uuid interface{}) *Database_GetOrganizationInvoices_Call { - return &Database_GetOrganizationInvoices_Call{Call: _e.mock.On("GetOrganizationInvoices", org_uuid)} +// GetPersonByUniqueName is a helper method to define mock.On call +// - un string +func (_e *Database_Expecter) GetPersonByUniqueName(un interface{}) *Database_GetPersonByUniqueName_Call { + return &Database_GetPersonByUniqueName_Call{Call: _e.mock.On("GetPersonByUniqueName", un)} } -func (_c *Database_GetOrganizationInvoices_Call) Run(run func(org_uuid string)) *Database_GetOrganizationInvoices_Call { +func (_c *Database_GetPersonByUniqueName_Call) Run(run func(un string)) *Database_GetPersonByUniqueName_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizationInvoices_Call) Return(_a0 []db.InvoiceList) *Database_GetOrganizationInvoices_Call { +func (_c *Database_GetPersonByUniqueName_Call) Return(_a0 db.Person) *Database_GetPersonByUniqueName_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationInvoices_Call) RunAndReturn(run func(string) []db.InvoiceList) *Database_GetOrganizationInvoices_Call { +func (_c *Database_GetPersonByUniqueName_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByUniqueName_Call { _c.Call.Return(run) return _c } -// GetOrganizationInvoicesCount provides a mock function with given fields: org_uuid -func (_m *Database) GetOrganizationInvoicesCount(org_uuid string) int64 { - ret := _m.Called(org_uuid) +// GetPersonByUuid provides a mock function with given fields: uuid +func (_m *Database) GetPersonByUuid(uuid string) db.Person { + ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for GetOrganizationInvoicesCount") + panic("no return value specified for GetPersonByUuid") } - var r0 int64 - if rf, ok := ret.Get(0).(func(string) int64); ok { - r0 = rf(org_uuid) + var r0 db.Person + if rf, ok := ret.Get(0).(func(string) db.Person); ok { + r0 = rf(uuid) } else { - r0 = ret.Get(0).(int64) + r0 = ret.Get(0).(db.Person) } return r0 } -// Database_GetOrganizationInvoicesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationInvoicesCount' -type Database_GetOrganizationInvoicesCount_Call struct { +// Database_GetPersonByUuid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByUuid' +type Database_GetPersonByUuid_Call struct { *mock.Call } -// GetOrganizationInvoicesCount is a helper method to define mock.On call -// - org_uuid string -func (_e *Database_Expecter) GetOrganizationInvoicesCount(org_uuid interface{}) *Database_GetOrganizationInvoicesCount_Call { - return &Database_GetOrganizationInvoicesCount_Call{Call: _e.mock.On("GetOrganizationInvoicesCount", org_uuid)} +// GetPersonByUuid is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetPersonByUuid(uuid interface{}) *Database_GetPersonByUuid_Call { + return &Database_GetPersonByUuid_Call{Call: _e.mock.On("GetPersonByUuid", uuid)} } -func (_c *Database_GetOrganizationInvoicesCount_Call) Run(run func(org_uuid string)) *Database_GetOrganizationInvoicesCount_Call { +func (_c *Database_GetPersonByUuid_Call) Run(run func(uuid string)) *Database_GetPersonByUuid_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizationInvoicesCount_Call) Return(_a0 int64) *Database_GetOrganizationInvoicesCount_Call { +func (_c *Database_GetPersonByUuid_Call) Return(_a0 db.Person) *Database_GetPersonByUuid_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationInvoicesCount_Call) RunAndReturn(run func(string) int64) *Database_GetOrganizationInvoicesCount_Call { +func (_c *Database_GetPersonByUuid_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByUuid_Call { _c.Call.Return(run) return _c } -// GetOrganizationStatusBudget provides a mock function with given fields: org_uuid -func (_m *Database) GetOrganizationStatusBudget(org_uuid string) db.StatusBudget { - ret := _m.Called(org_uuid) +// GetPreviousBountyByCreated provides a mock function with given fields: r +func (_m *Database) GetPreviousBountyByCreated(r *http.Request) (uint, error) { + ret := _m.Called(r) if len(ret) == 0 { - panic("no return value specified for GetOrganizationStatusBudget") + panic("no return value specified for GetPreviousBountyByCreated") } - var r0 db.StatusBudget - if rf, ok := ret.Get(0).(func(string) db.StatusBudget); ok { - r0 = rf(org_uuid) + var r0 uint + var r1 error + if rf, ok := ret.Get(0).(func(*http.Request) (uint, error)); ok { + return rf(r) + } + if rf, ok := ret.Get(0).(func(*http.Request) uint); ok { + r0 = rf(r) } else { - r0 = ret.Get(0).(db.StatusBudget) + r0 = ret.Get(0).(uint) } - return r0 + if rf, ok := ret.Get(1).(func(*http.Request) error); ok { + r1 = rf(r) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetOrganizationStatusBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationStatusBudget' -type Database_GetOrganizationStatusBudget_Call struct { +// Database_GetPreviousBountyByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousBountyByCreated' +type Database_GetPreviousBountyByCreated_Call struct { *mock.Call } -// GetOrganizationStatusBudget is a helper method to define mock.On call -// - org_uuid string -func (_e *Database_Expecter) GetOrganizationStatusBudget(org_uuid interface{}) *Database_GetOrganizationStatusBudget_Call { - return &Database_GetOrganizationStatusBudget_Call{Call: _e.mock.On("GetOrganizationStatusBudget", org_uuid)} +// GetPreviousBountyByCreated is a helper method to define mock.On call +// - r *http.Request +func (_e *Database_Expecter) GetPreviousBountyByCreated(r interface{}) *Database_GetPreviousBountyByCreated_Call { + return &Database_GetPreviousBountyByCreated_Call{Call: _e.mock.On("GetPreviousBountyByCreated", r)} } -func (_c *Database_GetOrganizationStatusBudget_Call) Run(run func(org_uuid string)) *Database_GetOrganizationStatusBudget_Call { +func (_c *Database_GetPreviousBountyByCreated_Call) Run(run func(r *http.Request)) *Database_GetPreviousBountyByCreated_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(*http.Request)) }) return _c } -func (_c *Database_GetOrganizationStatusBudget_Call) Return(_a0 db.StatusBudget) *Database_GetOrganizationStatusBudget_Call { - _c.Call.Return(_a0) +func (_c *Database_GetPreviousBountyByCreated_Call) Return(_a0 uint, _a1 error) *Database_GetPreviousBountyByCreated_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetOrganizationStatusBudget_Call) RunAndReturn(run func(string) db.StatusBudget) *Database_GetOrganizationStatusBudget_Call { +func (_c *Database_GetPreviousBountyByCreated_Call) RunAndReturn(run func(*http.Request) (uint, error)) *Database_GetPreviousBountyByCreated_Call { _c.Call.Return(run) return _c } -// GetOrganizationUser provides a mock function with given fields: pubkey, org_uuid -func (_m *Database) GetOrganizationUser(pubkey string, org_uuid string) db.OrganizationUsers { - ret := _m.Called(pubkey, org_uuid) +// GetPreviousWorkspaceBountyByCreated provides a mock function with given fields: r +func (_m *Database) GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, error) { + ret := _m.Called(r) if len(ret) == 0 { - panic("no return value specified for GetOrganizationUser") + panic("no return value specified for GetPreviousWorkspaceBountyByCreated") } - var r0 db.OrganizationUsers - if rf, ok := ret.Get(0).(func(string, string) db.OrganizationUsers); ok { - r0 = rf(pubkey, org_uuid) + var r0 uint + var r1 error + if rf, ok := ret.Get(0).(func(*http.Request) (uint, error)); ok { + return rf(r) + } + if rf, ok := ret.Get(0).(func(*http.Request) uint); ok { + r0 = rf(r) } else { - r0 = ret.Get(0).(db.OrganizationUsers) + r0 = ret.Get(0).(uint) } - return r0 + if rf, ok := ret.Get(1).(func(*http.Request) error); ok { + r1 = rf(r) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetOrganizationUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationUser' -type Database_GetOrganizationUser_Call struct { +// Database_GetPreviousWorkspaceBountyByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousWorkspaceBountyByCreated' +type Database_GetPreviousWorkspaceBountyByCreated_Call struct { *mock.Call } -// GetOrganizationUser is a helper method to define mock.On call -// - pubkey string -// - org_uuid string -func (_e *Database_Expecter) GetOrganizationUser(pubkey interface{}, org_uuid interface{}) *Database_GetOrganizationUser_Call { - return &Database_GetOrganizationUser_Call{Call: _e.mock.On("GetOrganizationUser", pubkey, org_uuid)} +// GetPreviousWorkspaceBountyByCreated is a helper method to define mock.On call +// - r *http.Request +func (_e *Database_Expecter) GetPreviousWorkspaceBountyByCreated(r interface{}) *Database_GetPreviousWorkspaceBountyByCreated_Call { + return &Database_GetPreviousWorkspaceBountyByCreated_Call{Call: _e.mock.On("GetPreviousWorkspaceBountyByCreated", r)} } -func (_c *Database_GetOrganizationUser_Call) Run(run func(pubkey string, org_uuid string)) *Database_GetOrganizationUser_Call { +func (_c *Database_GetPreviousWorkspaceBountyByCreated_Call) Run(run func(r *http.Request)) *Database_GetPreviousWorkspaceBountyByCreated_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string)) + run(args[0].(*http.Request)) }) return _c } -func (_c *Database_GetOrganizationUser_Call) Return(_a0 db.OrganizationUsers) *Database_GetOrganizationUser_Call { - _c.Call.Return(_a0) +func (_c *Database_GetPreviousWorkspaceBountyByCreated_Call) Return(_a0 uint, _a1 error) *Database_GetPreviousWorkspaceBountyByCreated_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetOrganizationUser_Call) RunAndReturn(run func(string, string) db.OrganizationUsers) *Database_GetOrganizationUser_Call { +func (_c *Database_GetPreviousWorkspaceBountyByCreated_Call) RunAndReturn(run func(*http.Request) (uint, error)) *Database_GetPreviousWorkspaceBountyByCreated_Call { _c.Call.Return(run) return _c } -// GetOrganizationUsers provides a mock function with given fields: uuid -func (_m *Database) GetOrganizationUsers(uuid string) ([]db.OrganizationUsersData, error) { +// GetTribe provides a mock function with given fields: uuid +func (_m *Database) GetTribe(uuid string) db.Tribe { ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for GetOrganizationUsers") + panic("no return value specified for GetTribe") } - var r0 []db.OrganizationUsersData - var r1 error - if rf, ok := ret.Get(0).(func(string) ([]db.OrganizationUsersData, error)); ok { - return rf(uuid) - } - if rf, ok := ret.Get(0).(func(string) []db.OrganizationUsersData); ok { + var r0 db.Tribe + if rf, ok := ret.Get(0).(func(string) db.Tribe); ok { r0 = rf(uuid) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.OrganizationUsersData) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(uuid) - } else { - r1 = ret.Error(1) + r0 = ret.Get(0).(db.Tribe) } - return r0, r1 + return r0 } -// Database_GetOrganizationUsers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationUsers' -type Database_GetOrganizationUsers_Call struct { +// Database_GetTribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribe' +type Database_GetTribe_Call struct { *mock.Call } -// GetOrganizationUsers is a helper method to define mock.On call +// GetTribe is a helper method to define mock.On call // - uuid string -func (_e *Database_Expecter) GetOrganizationUsers(uuid interface{}) *Database_GetOrganizationUsers_Call { - return &Database_GetOrganizationUsers_Call{Call: _e.mock.On("GetOrganizationUsers", uuid)} +func (_e *Database_Expecter) GetTribe(uuid interface{}) *Database_GetTribe_Call { + return &Database_GetTribe_Call{Call: _e.mock.On("GetTribe", uuid)} } -func (_c *Database_GetOrganizationUsers_Call) Run(run func(uuid string)) *Database_GetOrganizationUsers_Call { +func (_c *Database_GetTribe_Call) Run(run func(uuid string)) *Database_GetTribe_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizationUsers_Call) Return(_a0 []db.OrganizationUsersData, _a1 error) *Database_GetOrganizationUsers_Call { - _c.Call.Return(_a0, _a1) +func (_c *Database_GetTribe_Call) Return(_a0 db.Tribe) *Database_GetTribe_Call { + _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationUsers_Call) RunAndReturn(run func(string) ([]db.OrganizationUsersData, error)) *Database_GetOrganizationUsers_Call { +func (_c *Database_GetTribe_Call) RunAndReturn(run func(string) db.Tribe) *Database_GetTribe_Call { _c.Call.Return(run) return _c } -// GetOrganizationUsersCount provides a mock function with given fields: uuid -func (_m *Database) GetOrganizationUsersCount(uuid string) int64 { - ret := _m.Called(uuid) +// GetTribeByIdAndPubkey provides a mock function with given fields: uuid, pubkey +func (_m *Database) GetTribeByIdAndPubkey(uuid string, pubkey string) db.Tribe { + ret := _m.Called(uuid, pubkey) if len(ret) == 0 { - panic("no return value specified for GetOrganizationUsersCount") + panic("no return value specified for GetTribeByIdAndPubkey") } - var r0 int64 - if rf, ok := ret.Get(0).(func(string) int64); ok { - r0 = rf(uuid) + var r0 db.Tribe + if rf, ok := ret.Get(0).(func(string, string) db.Tribe); ok { + r0 = rf(uuid, pubkey) } else { - r0 = ret.Get(0).(int64) + r0 = ret.Get(0).(db.Tribe) } return r0 } -// Database_GetOrganizationUsersCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationUsersCount' -type Database_GetOrganizationUsersCount_Call struct { +// Database_GetTribeByIdAndPubkey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribeByIdAndPubkey' +type Database_GetTribeByIdAndPubkey_Call struct { *mock.Call } -// GetOrganizationUsersCount is a helper method to define mock.On call +// GetTribeByIdAndPubkey is a helper method to define mock.On call // - uuid string -func (_e *Database_Expecter) GetOrganizationUsersCount(uuid interface{}) *Database_GetOrganizationUsersCount_Call { - return &Database_GetOrganizationUsersCount_Call{Call: _e.mock.On("GetOrganizationUsersCount", uuid)} +// - pubkey string +func (_e *Database_Expecter) GetTribeByIdAndPubkey(uuid interface{}, pubkey interface{}) *Database_GetTribeByIdAndPubkey_Call { + return &Database_GetTribeByIdAndPubkey_Call{Call: _e.mock.On("GetTribeByIdAndPubkey", uuid, pubkey)} } -func (_c *Database_GetOrganizationUsersCount_Call) Run(run func(uuid string)) *Database_GetOrganizationUsersCount_Call { +func (_c *Database_GetTribeByIdAndPubkey_Call) Run(run func(uuid string, pubkey string)) *Database_GetTribeByIdAndPubkey_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(string), args[1].(string)) }) return _c } -func (_c *Database_GetOrganizationUsersCount_Call) Return(_a0 int64) *Database_GetOrganizationUsersCount_Call { +func (_c *Database_GetTribeByIdAndPubkey_Call) Return(_a0 db.Tribe) *Database_GetTribeByIdAndPubkey_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationUsersCount_Call) RunAndReturn(run func(string) int64) *Database_GetOrganizationUsersCount_Call { +func (_c *Database_GetTribeByIdAndPubkey_Call) RunAndReturn(run func(string, string) db.Tribe) *Database_GetTribeByIdAndPubkey_Call { _c.Call.Return(run) return _c } -// GetOrganizations provides a mock function with given fields: r -func (_m *Database) GetOrganizations(r *http.Request) []db.Organization { - ret := _m.Called(r) +// GetTribeByUniqueName provides a mock function with given fields: un +func (_m *Database) GetTribeByUniqueName(un string) db.Tribe { + ret := _m.Called(un) if len(ret) == 0 { - panic("no return value specified for GetOrganizations") + panic("no return value specified for GetTribeByUniqueName") } - var r0 []db.Organization - if rf, ok := ret.Get(0).(func(*http.Request) []db.Organization); ok { - r0 = rf(r) + var r0 db.Tribe + if rf, ok := ret.Get(0).(func(string) db.Tribe); ok { + r0 = rf(un) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Organization) - } + r0 = ret.Get(0).(db.Tribe) } return r0 } -// Database_GetOrganizations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizations' -type Database_GetOrganizations_Call struct { +// Database_GetTribeByUniqueName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribeByUniqueName' +type Database_GetTribeByUniqueName_Call struct { *mock.Call } -// GetOrganizations is a helper method to define mock.On call -// - r *http.Request -func (_e *Database_Expecter) GetOrganizations(r interface{}) *Database_GetOrganizations_Call { - return &Database_GetOrganizations_Call{Call: _e.mock.On("GetOrganizations", r)} +// GetTribeByUniqueName is a helper method to define mock.On call +// - un string +func (_e *Database_Expecter) GetTribeByUniqueName(un interface{}) *Database_GetTribeByUniqueName_Call { + return &Database_GetTribeByUniqueName_Call{Call: _e.mock.On("GetTribeByUniqueName", un)} } -func (_c *Database_GetOrganizations_Call) Run(run func(r *http.Request)) *Database_GetOrganizations_Call { +func (_c *Database_GetTribeByUniqueName_Call) Run(run func(un string)) *Database_GetTribeByUniqueName_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizations_Call) Return(_a0 []db.Organization) *Database_GetOrganizations_Call { +func (_c *Database_GetTribeByUniqueName_Call) Return(_a0 db.Tribe) *Database_GetTribeByUniqueName_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizations_Call) RunAndReturn(run func(*http.Request) []db.Organization) *Database_GetOrganizations_Call { +func (_c *Database_GetTribeByUniqueName_Call) RunAndReturn(run func(string) db.Tribe) *Database_GetTribeByUniqueName_Call { _c.Call.Return(run) return _c } -// GetOrganizationsCount provides a mock function with given fields: -func (_m *Database) GetOrganizationsCount() int64 { - ret := _m.Called() +// GetTribesByAppUrl provides a mock function with given fields: aurl +func (_m *Database) GetTribesByAppUrl(aurl string) []db.Tribe { + ret := _m.Called(aurl) if len(ret) == 0 { - panic("no return value specified for GetOrganizationsCount") + panic("no return value specified for GetTribesByAppUrl") } - var r0 int64 - if rf, ok := ret.Get(0).(func() int64); ok { - r0 = rf() + var r0 []db.Tribe + if rf, ok := ret.Get(0).(func(string) []db.Tribe); ok { + r0 = rf(aurl) } else { - r0 = ret.Get(0).(int64) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.Tribe) + } } return r0 } -// Database_GetOrganizationsCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrganizationsCount' -type Database_GetOrganizationsCount_Call struct { +// Database_GetTribesByAppUrl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribesByAppUrl' +type Database_GetTribesByAppUrl_Call struct { *mock.Call } -// GetOrganizationsCount is a helper method to define mock.On call -func (_e *Database_Expecter) GetOrganizationsCount() *Database_GetOrganizationsCount_Call { - return &Database_GetOrganizationsCount_Call{Call: _e.mock.On("GetOrganizationsCount")} +// GetTribesByAppUrl is a helper method to define mock.On call +// - aurl string +func (_e *Database_Expecter) GetTribesByAppUrl(aurl interface{}) *Database_GetTribesByAppUrl_Call { + return &Database_GetTribesByAppUrl_Call{Call: _e.mock.On("GetTribesByAppUrl", aurl)} } -func (_c *Database_GetOrganizationsCount_Call) Run(run func()) *Database_GetOrganizationsCount_Call { +func (_c *Database_GetTribesByAppUrl_Call) Run(run func(aurl string)) *Database_GetTribesByAppUrl_Call { _c.Call.Run(func(args mock.Arguments) { - run() + run(args[0].(string)) }) return _c } -func (_c *Database_GetOrganizationsCount_Call) Return(_a0 int64) *Database_GetOrganizationsCount_Call { +func (_c *Database_GetTribesByAppUrl_Call) Return(_a0 []db.Tribe) *Database_GetTribesByAppUrl_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetOrganizationsCount_Call) RunAndReturn(run func() int64) *Database_GetOrganizationsCount_Call { +func (_c *Database_GetTribesByAppUrl_Call) RunAndReturn(run func(string) []db.Tribe) *Database_GetTribesByAppUrl_Call { _c.Call.Return(run) return _c } -// GetPaymentHistory provides a mock function with given fields: org_uuid, r -func (_m *Database) GetPaymentHistory(org_uuid string, r *http.Request) []db.PaymentHistory { - ret := _m.Called(org_uuid, r) +// GetTribesByOwner provides a mock function with given fields: pubkey +func (_m *Database) GetTribesByOwner(pubkey string) []db.Tribe { + ret := _m.Called(pubkey) if len(ret) == 0 { - panic("no return value specified for GetPaymentHistory") + panic("no return value specified for GetTribesByOwner") } - var r0 []db.PaymentHistory - if rf, ok := ret.Get(0).(func(string, *http.Request) []db.PaymentHistory); ok { - r0 = rf(org_uuid, r) + var r0 []db.Tribe + if rf, ok := ret.Get(0).(func(string) []db.Tribe); ok { + r0 = rf(pubkey) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.PaymentHistory) + r0 = ret.Get(0).([]db.Tribe) } } return r0 } -// Database_GetPaymentHistory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPaymentHistory' -type Database_GetPaymentHistory_Call struct { +// Database_GetTribesByOwner_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribesByOwner' +type Database_GetTribesByOwner_Call struct { *mock.Call } -// GetPaymentHistory is a helper method to define mock.On call -// - org_uuid string -// - r *http.Request -func (_e *Database_Expecter) GetPaymentHistory(org_uuid interface{}, r interface{}) *Database_GetPaymentHistory_Call { - return &Database_GetPaymentHistory_Call{Call: _e.mock.On("GetPaymentHistory", org_uuid, r)} +// GetTribesByOwner is a helper method to define mock.On call +// - pubkey string +func (_e *Database_Expecter) GetTribesByOwner(pubkey interface{}) *Database_GetTribesByOwner_Call { + return &Database_GetTribesByOwner_Call{Call: _e.mock.On("GetTribesByOwner", pubkey)} } -func (_c *Database_GetPaymentHistory_Call) Run(run func(org_uuid string, r *http.Request)) *Database_GetPaymentHistory_Call { +func (_c *Database_GetTribesByOwner_Call) Run(run func(pubkey string)) *Database_GetTribesByOwner_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(*http.Request)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetPaymentHistory_Call) Return(_a0 []db.PaymentHistory) *Database_GetPaymentHistory_Call { +func (_c *Database_GetTribesByOwner_Call) Return(_a0 []db.Tribe) *Database_GetTribesByOwner_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPaymentHistory_Call) RunAndReturn(run func(string, *http.Request) []db.PaymentHistory) *Database_GetPaymentHistory_Call { +func (_c *Database_GetTribesByOwner_Call) RunAndReturn(run func(string) []db.Tribe) *Database_GetTribesByOwner_Call { _c.Call.Return(run) return _c } -// GetPaymentHistoryByCreated provides a mock function with given fields: created, org_uuid -func (_m *Database) GetPaymentHistoryByCreated(created *time.Time, org_uuid string) db.PaymentHistory { - ret := _m.Called(created, org_uuid) +// GetTribesTotal provides a mock function with given fields: +func (_m *Database) GetTribesTotal() int64 { + ret := _m.Called() if len(ret) == 0 { - panic("no return value specified for GetPaymentHistoryByCreated") + panic("no return value specified for GetTribesTotal") } - var r0 db.PaymentHistory - if rf, ok := ret.Get(0).(func(*time.Time, string) db.PaymentHistory); ok { - r0 = rf(created, org_uuid) + var r0 int64 + if rf, ok := ret.Get(0).(func() int64); ok { + r0 = rf() } else { - r0 = ret.Get(0).(db.PaymentHistory) + r0 = ret.Get(0).(int64) } return r0 } -// Database_GetPaymentHistoryByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPaymentHistoryByCreated' -type Database_GetPaymentHistoryByCreated_Call struct { +// Database_GetTribesTotal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribesTotal' +type Database_GetTribesTotal_Call struct { *mock.Call } -// GetPaymentHistoryByCreated is a helper method to define mock.On call -// - created *time.Time -// - org_uuid string -func (_e *Database_Expecter) GetPaymentHistoryByCreated(created interface{}, org_uuid interface{}) *Database_GetPaymentHistoryByCreated_Call { - return &Database_GetPaymentHistoryByCreated_Call{Call: _e.mock.On("GetPaymentHistoryByCreated", created, org_uuid)} +// GetTribesTotal is a helper method to define mock.On call +func (_e *Database_Expecter) GetTribesTotal() *Database_GetTribesTotal_Call { + return &Database_GetTribesTotal_Call{Call: _e.mock.On("GetTribesTotal")} } -func (_c *Database_GetPaymentHistoryByCreated_Call) Run(run func(created *time.Time, org_uuid string)) *Database_GetPaymentHistoryByCreated_Call { +func (_c *Database_GetTribesTotal_Call) Run(run func()) *Database_GetTribesTotal_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*time.Time), args[1].(string)) + run() }) return _c } -func (_c *Database_GetPaymentHistoryByCreated_Call) Return(_a0 db.PaymentHistory) *Database_GetPaymentHistoryByCreated_Call { +func (_c *Database_GetTribesTotal_Call) Return(_a0 int64) *Database_GetTribesTotal_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPaymentHistoryByCreated_Call) RunAndReturn(run func(*time.Time, string) db.PaymentHistory) *Database_GetPaymentHistoryByCreated_Call { +func (_c *Database_GetTribesTotal_Call) RunAndReturn(run func() int64) *Database_GetTribesTotal_Call { _c.Call.Return(run) return _c } -// GetPeopleBySearch provides a mock function with given fields: r -func (_m *Database) GetPeopleBySearch(r *http.Request) []db.Person { - ret := _m.Called(r) +// GetUnconfirmedGithub provides a mock function with given fields: +func (_m *Database) GetUnconfirmedGithub() []db.Person { + ret := _m.Called() if len(ret) == 0 { - panic("no return value specified for GetPeopleBySearch") + panic("no return value specified for GetUnconfirmedGithub") } var r0 []db.Person - if rf, ok := ret.Get(0).(func(*http.Request) []db.Person); ok { - r0 = rf(r) + if rf, ok := ret.Get(0).(func() []db.Person); ok { + r0 = rf() } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]db.Person) @@ -4054,670 +4060,656 @@ func (_m *Database) GetPeopleBySearch(r *http.Request) []db.Person { return r0 } -// Database_GetPeopleBySearch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPeopleBySearch' -type Database_GetPeopleBySearch_Call struct { +// Database_GetUnconfirmedGithub_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUnconfirmedGithub' +type Database_GetUnconfirmedGithub_Call struct { *mock.Call } -// GetPeopleBySearch is a helper method to define mock.On call -// - r *http.Request -func (_e *Database_Expecter) GetPeopleBySearch(r interface{}) *Database_GetPeopleBySearch_Call { - return &Database_GetPeopleBySearch_Call{Call: _e.mock.On("GetPeopleBySearch", r)} +// GetUnconfirmedGithub is a helper method to define mock.On call +func (_e *Database_Expecter) GetUnconfirmedGithub() *Database_GetUnconfirmedGithub_Call { + return &Database_GetUnconfirmedGithub_Call{Call: _e.mock.On("GetUnconfirmedGithub")} } -func (_c *Database_GetPeopleBySearch_Call) Run(run func(r *http.Request)) *Database_GetPeopleBySearch_Call { +func (_c *Database_GetUnconfirmedGithub_Call) Run(run func()) *Database_GetUnconfirmedGithub_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request)) + run() }) return _c } -func (_c *Database_GetPeopleBySearch_Call) Return(_a0 []db.Person) *Database_GetPeopleBySearch_Call { +func (_c *Database_GetUnconfirmedGithub_Call) Return(_a0 []db.Person) *Database_GetUnconfirmedGithub_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPeopleBySearch_Call) RunAndReturn(run func(*http.Request) []db.Person) *Database_GetPeopleBySearch_Call { +func (_c *Database_GetUnconfirmedGithub_Call) RunAndReturn(run func() []db.Person) *Database_GetUnconfirmedGithub_Call { _c.Call.Return(run) return _c } -// GetPeopleListShort provides a mock function with given fields: count -func (_m *Database) GetPeopleListShort(count uint32) *[]db.PersonInShort { - ret := _m.Called(count) +// GetUnconfirmedTwitter provides a mock function with given fields: +func (_m *Database) GetUnconfirmedTwitter() []db.Person { + ret := _m.Called() if len(ret) == 0 { - panic("no return value specified for GetPeopleListShort") + panic("no return value specified for GetUnconfirmedTwitter") } - var r0 *[]db.PersonInShort - if rf, ok := ret.Get(0).(func(uint32) *[]db.PersonInShort); ok { - r0 = rf(count) + var r0 []db.Person + if rf, ok := ret.Get(0).(func() []db.Person); ok { + r0 = rf() } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*[]db.PersonInShort) + r0 = ret.Get(0).([]db.Person) } } return r0 } -// Database_GetPeopleListShort_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPeopleListShort' -type Database_GetPeopleListShort_Call struct { +// Database_GetUnconfirmedTwitter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUnconfirmedTwitter' +type Database_GetUnconfirmedTwitter_Call struct { *mock.Call } -// GetPeopleListShort is a helper method to define mock.On call -// - count uint32 -func (_e *Database_Expecter) GetPeopleListShort(count interface{}) *Database_GetPeopleListShort_Call { - return &Database_GetPeopleListShort_Call{Call: _e.mock.On("GetPeopleListShort", count)} +// GetUnconfirmedTwitter is a helper method to define mock.On call +func (_e *Database_Expecter) GetUnconfirmedTwitter() *Database_GetUnconfirmedTwitter_Call { + return &Database_GetUnconfirmedTwitter_Call{Call: _e.mock.On("GetUnconfirmedTwitter")} } -func (_c *Database_GetPeopleListShort_Call) Run(run func(count uint32)) *Database_GetPeopleListShort_Call { +func (_c *Database_GetUnconfirmedTwitter_Call) Run(run func()) *Database_GetUnconfirmedTwitter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint32)) + run() }) return _c } -func (_c *Database_GetPeopleListShort_Call) Return(_a0 *[]db.PersonInShort) *Database_GetPeopleListShort_Call { +func (_c *Database_GetUnconfirmedTwitter_Call) Return(_a0 []db.Person) *Database_GetUnconfirmedTwitter_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPeopleListShort_Call) RunAndReturn(run func(uint32) *[]db.PersonInShort) *Database_GetPeopleListShort_Call { +func (_c *Database_GetUnconfirmedTwitter_Call) RunAndReturn(run func() []db.Person) *Database_GetUnconfirmedTwitter_Call { _c.Call.Return(run) return _c } -// GetPerson provides a mock function with given fields: id -func (_m *Database) GetPerson(id uint) db.Person { - ret := _m.Called(id) +// GetUserAssignedWorkspaces provides a mock function with given fields: pubkey +func (_m *Database) GetUserAssignedWorkspaces(pubkey string) []db.OrganizationUsers { + ret := _m.Called(pubkey) if len(ret) == 0 { - panic("no return value specified for GetPerson") + panic("no return value specified for GetUserAssignedWorkspaces") } - var r0 db.Person - if rf, ok := ret.Get(0).(func(uint) db.Person); ok { - r0 = rf(id) + var r0 []db.OrganizationUsers + if rf, ok := ret.Get(0).(func(string) []db.OrganizationUsers); ok { + r0 = rf(pubkey) } else { - r0 = ret.Get(0).(db.Person) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.OrganizationUsers) + } } return r0 } -// Database_GetPerson_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPerson' -type Database_GetPerson_Call struct { +// Database_GetUserAssignedWorkspaces_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserAssignedWorkspaces' +type Database_GetUserAssignedWorkspaces_Call struct { *mock.Call } -// GetPerson is a helper method to define mock.On call -// - id uint -func (_e *Database_Expecter) GetPerson(id interface{}) *Database_GetPerson_Call { - return &Database_GetPerson_Call{Call: _e.mock.On("GetPerson", id)} +// GetUserAssignedWorkspaces is a helper method to define mock.On call +// - pubkey string +func (_e *Database_Expecter) GetUserAssignedWorkspaces(pubkey interface{}) *Database_GetUserAssignedWorkspaces_Call { + return &Database_GetUserAssignedWorkspaces_Call{Call: _e.mock.On("GetUserAssignedWorkspaces", pubkey)} } -func (_c *Database_GetPerson_Call) Run(run func(id uint)) *Database_GetPerson_Call { +func (_c *Database_GetUserAssignedWorkspaces_Call) Run(run func(pubkey string)) *Database_GetUserAssignedWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(uint)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetPerson_Call) Return(_a0 db.Person) *Database_GetPerson_Call { +func (_c *Database_GetUserAssignedWorkspaces_Call) Return(_a0 []db.OrganizationUsers) *Database_GetUserAssignedWorkspaces_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPerson_Call) RunAndReturn(run func(uint) db.Person) *Database_GetPerson_Call { +func (_c *Database_GetUserAssignedWorkspaces_Call) RunAndReturn(run func(string) []db.OrganizationUsers) *Database_GetUserAssignedWorkspaces_Call { _c.Call.Return(run) return _c } -// GetPersonByGithubName provides a mock function with given fields: github_name -func (_m *Database) GetPersonByGithubName(github_name string) db.Person { - ret := _m.Called(github_name) +// GetUserBountiesCount provides a mock function with given fields: personKey, tabType +func (_m *Database) GetUserBountiesCount(personKey string, tabType string) int64 { + ret := _m.Called(personKey, tabType) if len(ret) == 0 { - panic("no return value specified for GetPersonByGithubName") + panic("no return value specified for GetUserBountiesCount") } - var r0 db.Person - if rf, ok := ret.Get(0).(func(string) db.Person); ok { - r0 = rf(github_name) + var r0 int64 + if rf, ok := ret.Get(0).(func(string, string) int64); ok { + r0 = rf(personKey, tabType) } else { - r0 = ret.Get(0).(db.Person) + r0 = ret.Get(0).(int64) } return r0 } -// Database_GetPersonByGithubName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByGithubName' -type Database_GetPersonByGithubName_Call struct { +// Database_GetUserBountiesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserBountiesCount' +type Database_GetUserBountiesCount_Call struct { *mock.Call } -// GetPersonByGithubName is a helper method to define mock.On call -// - github_name string -func (_e *Database_Expecter) GetPersonByGithubName(github_name interface{}) *Database_GetPersonByGithubName_Call { - return &Database_GetPersonByGithubName_Call{Call: _e.mock.On("GetPersonByGithubName", github_name)} +// GetUserBountiesCount is a helper method to define mock.On call +// - personKey string +// - tabType string +func (_e *Database_Expecter) GetUserBountiesCount(personKey interface{}, tabType interface{}) *Database_GetUserBountiesCount_Call { + return &Database_GetUserBountiesCount_Call{Call: _e.mock.On("GetUserBountiesCount", personKey, tabType)} } -func (_c *Database_GetPersonByGithubName_Call) Run(run func(github_name string)) *Database_GetPersonByGithubName_Call { +func (_c *Database_GetUserBountiesCount_Call) Run(run func(personKey string, tabType string)) *Database_GetUserBountiesCount_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(string), args[1].(string)) }) return _c } -func (_c *Database_GetPersonByGithubName_Call) Return(_a0 db.Person) *Database_GetPersonByGithubName_Call { +func (_c *Database_GetUserBountiesCount_Call) Return(_a0 int64) *Database_GetUserBountiesCount_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPersonByGithubName_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByGithubName_Call { +func (_c *Database_GetUserBountiesCount_Call) RunAndReturn(run func(string, string) int64) *Database_GetUserBountiesCount_Call { _c.Call.Return(run) return _c } -// GetPersonByPubkey provides a mock function with given fields: pubkey -func (_m *Database) GetPersonByPubkey(pubkey string) db.Person { +// GetUserCreatedWorkspaces provides a mock function with given fields: pubkey +func (_m *Database) GetUserCreatedWorkspaces(pubkey string) []db.Organization { ret := _m.Called(pubkey) if len(ret) == 0 { - panic("no return value specified for GetPersonByPubkey") + panic("no return value specified for GetUserCreatedWorkspaces") } - var r0 db.Person - if rf, ok := ret.Get(0).(func(string) db.Person); ok { + var r0 []db.Organization + if rf, ok := ret.Get(0).(func(string) []db.Organization); ok { r0 = rf(pubkey) } else { - r0 = ret.Get(0).(db.Person) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.Organization) + } } return r0 } -// Database_GetPersonByPubkey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByPubkey' -type Database_GetPersonByPubkey_Call struct { +// Database_GetUserCreatedWorkspaces_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserCreatedWorkspaces' +type Database_GetUserCreatedWorkspaces_Call struct { *mock.Call } -// GetPersonByPubkey is a helper method to define mock.On call +// GetUserCreatedWorkspaces is a helper method to define mock.On call // - pubkey string -func (_e *Database_Expecter) GetPersonByPubkey(pubkey interface{}) *Database_GetPersonByPubkey_Call { - return &Database_GetPersonByPubkey_Call{Call: _e.mock.On("GetPersonByPubkey", pubkey)} +func (_e *Database_Expecter) GetUserCreatedWorkspaces(pubkey interface{}) *Database_GetUserCreatedWorkspaces_Call { + return &Database_GetUserCreatedWorkspaces_Call{Call: _e.mock.On("GetUserCreatedWorkspaces", pubkey)} } -func (_c *Database_GetPersonByPubkey_Call) Run(run func(pubkey string)) *Database_GetPersonByPubkey_Call { +func (_c *Database_GetUserCreatedWorkspaces_Call) Run(run func(pubkey string)) *Database_GetUserCreatedWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetPersonByPubkey_Call) Return(_a0 db.Person) *Database_GetPersonByPubkey_Call { +func (_c *Database_GetUserCreatedWorkspaces_Call) Return(_a0 []db.Organization) *Database_GetUserCreatedWorkspaces_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPersonByPubkey_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByPubkey_Call { +func (_c *Database_GetUserCreatedWorkspaces_Call) RunAndReturn(run func(string) []db.Organization) *Database_GetUserCreatedWorkspaces_Call { _c.Call.Return(run) return _c } -// GetPersonByUniqueName provides a mock function with given fields: un -func (_m *Database) GetPersonByUniqueName(un string) db.Person { - ret := _m.Called(un) +// GetUserInvoiceData provides a mock function with given fields: payment_request +func (_m *Database) GetUserInvoiceData(payment_request string) db.UserInvoiceData { + ret := _m.Called(payment_request) if len(ret) == 0 { - panic("no return value specified for GetPersonByUniqueName") + panic("no return value specified for GetUserInvoiceData") } - var r0 db.Person - if rf, ok := ret.Get(0).(func(string) db.Person); ok { - r0 = rf(un) + var r0 db.UserInvoiceData + if rf, ok := ret.Get(0).(func(string) db.UserInvoiceData); ok { + r0 = rf(payment_request) } else { - r0 = ret.Get(0).(db.Person) + r0 = ret.Get(0).(db.UserInvoiceData) } return r0 } -// Database_GetPersonByUniqueName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByUniqueName' -type Database_GetPersonByUniqueName_Call struct { +// Database_GetUserInvoiceData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserInvoiceData' +type Database_GetUserInvoiceData_Call struct { *mock.Call } -// GetPersonByUniqueName is a helper method to define mock.On call -// - un string -func (_e *Database_Expecter) GetPersonByUniqueName(un interface{}) *Database_GetPersonByUniqueName_Call { - return &Database_GetPersonByUniqueName_Call{Call: _e.mock.On("GetPersonByUniqueName", un)} +// GetUserInvoiceData is a helper method to define mock.On call +// - payment_request string +func (_e *Database_Expecter) GetUserInvoiceData(payment_request interface{}) *Database_GetUserInvoiceData_Call { + return &Database_GetUserInvoiceData_Call{Call: _e.mock.On("GetUserInvoiceData", payment_request)} } -func (_c *Database_GetPersonByUniqueName_Call) Run(run func(un string)) *Database_GetPersonByUniqueName_Call { +func (_c *Database_GetUserInvoiceData_Call) Run(run func(payment_request string)) *Database_GetUserInvoiceData_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetPersonByUniqueName_Call) Return(_a0 db.Person) *Database_GetPersonByUniqueName_Call { +func (_c *Database_GetUserInvoiceData_Call) Return(_a0 db.UserInvoiceData) *Database_GetUserInvoiceData_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPersonByUniqueName_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByUniqueName_Call { +func (_c *Database_GetUserInvoiceData_Call) RunAndReturn(run func(string) db.UserInvoiceData) *Database_GetUserInvoiceData_Call { _c.Call.Return(run) return _c -} - -// GetPersonByUuid provides a mock function with given fields: uuid -func (_m *Database) GetPersonByUuid(uuid string) db.Person { - ret := _m.Called(uuid) +} + +// GetWorkspaceBounties provides a mock function with given fields: r, org_uuid +func (_m *Database) GetWorkspaceBounties(r *http.Request, org_uuid string) []db.Bounty { + ret := _m.Called(r, org_uuid) if len(ret) == 0 { - panic("no return value specified for GetPersonByUuid") + panic("no return value specified for GetWorkspaceBounties") } - var r0 db.Person - if rf, ok := ret.Get(0).(func(string) db.Person); ok { - r0 = rf(uuid) + var r0 []db.Bounty + if rf, ok := ret.Get(0).(func(*http.Request, string) []db.Bounty); ok { + r0 = rf(r, org_uuid) } else { - r0 = ret.Get(0).(db.Person) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.Bounty) + } } return r0 } -// Database_GetPersonByUuid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPersonByUuid' -type Database_GetPersonByUuid_Call struct { +// Database_GetWorkspaceBounties_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBounties' +type Database_GetWorkspaceBounties_Call struct { *mock.Call } -// GetPersonByUuid is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) GetPersonByUuid(uuid interface{}) *Database_GetPersonByUuid_Call { - return &Database_GetPersonByUuid_Call{Call: _e.mock.On("GetPersonByUuid", uuid)} +// GetWorkspaceBounties is a helper method to define mock.On call +// - r *http.Request +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceBounties(r interface{}, org_uuid interface{}) *Database_GetWorkspaceBounties_Call { + return &Database_GetWorkspaceBounties_Call{Call: _e.mock.On("GetWorkspaceBounties", r, org_uuid)} } -func (_c *Database_GetPersonByUuid_Call) Run(run func(uuid string)) *Database_GetPersonByUuid_Call { +func (_c *Database_GetWorkspaceBounties_Call) Run(run func(r *http.Request, org_uuid string)) *Database_GetWorkspaceBounties_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(*http.Request), args[1].(string)) }) return _c } -func (_c *Database_GetPersonByUuid_Call) Return(_a0 db.Person) *Database_GetPersonByUuid_Call { +func (_c *Database_GetWorkspaceBounties_Call) Return(_a0 []db.Bounty) *Database_GetWorkspaceBounties_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetPersonByUuid_Call) RunAndReturn(run func(string) db.Person) *Database_GetPersonByUuid_Call { +func (_c *Database_GetWorkspaceBounties_Call) RunAndReturn(run func(*http.Request, string) []db.Bounty) *Database_GetWorkspaceBounties_Call { _c.Call.Return(run) return _c } -// GetPreviousBountyByCreated provides a mock function with given fields: r -func (_m *Database) GetPreviousBountyByCreated(r *http.Request) (uint, error) { - ret := _m.Called(r) +// GetWorkspaceBountiesCount provides a mock function with given fields: r, org_uuid +func (_m *Database) GetWorkspaceBountiesCount(r *http.Request, org_uuid string) int64 { + ret := _m.Called(r, org_uuid) if len(ret) == 0 { - panic("no return value specified for GetPreviousBountyByCreated") + panic("no return value specified for GetWorkspaceBountiesCount") } - var r0 uint - var r1 error - if rf, ok := ret.Get(0).(func(*http.Request) (uint, error)); ok { - return rf(r) - } - if rf, ok := ret.Get(0).(func(*http.Request) uint); ok { - r0 = rf(r) - } else { - r0 = ret.Get(0).(uint) - } - - if rf, ok := ret.Get(1).(func(*http.Request) error); ok { - r1 = rf(r) + var r0 int64 + if rf, ok := ret.Get(0).(func(*http.Request, string) int64); ok { + r0 = rf(r, org_uuid) } else { - r1 = ret.Error(1) + r0 = ret.Get(0).(int64) } - return r0, r1 + return r0 } -// Database_GetPreviousBountyByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousBountyByCreated' -type Database_GetPreviousBountyByCreated_Call struct { +// Database_GetWorkspaceBountiesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBountiesCount' +type Database_GetWorkspaceBountiesCount_Call struct { *mock.Call } -// GetPreviousBountyByCreated is a helper method to define mock.On call +// GetWorkspaceBountiesCount is a helper method to define mock.On call // - r *http.Request -func (_e *Database_Expecter) GetPreviousBountyByCreated(r interface{}) *Database_GetPreviousBountyByCreated_Call { - return &Database_GetPreviousBountyByCreated_Call{Call: _e.mock.On("GetPreviousBountyByCreated", r)} +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceBountiesCount(r interface{}, org_uuid interface{}) *Database_GetWorkspaceBountiesCount_Call { + return &Database_GetWorkspaceBountiesCount_Call{Call: _e.mock.On("GetWorkspaceBountiesCount", r, org_uuid)} } -func (_c *Database_GetPreviousBountyByCreated_Call) Run(run func(r *http.Request)) *Database_GetPreviousBountyByCreated_Call { +func (_c *Database_GetWorkspaceBountiesCount_Call) Run(run func(r *http.Request, org_uuid string)) *Database_GetWorkspaceBountiesCount_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request)) + run(args[0].(*http.Request), args[1].(string)) }) return _c } -func (_c *Database_GetPreviousBountyByCreated_Call) Return(_a0 uint, _a1 error) *Database_GetPreviousBountyByCreated_Call { - _c.Call.Return(_a0, _a1) +func (_c *Database_GetWorkspaceBountiesCount_Call) Return(_a0 int64) *Database_GetWorkspaceBountiesCount_Call { + _c.Call.Return(_a0) return _c } -func (_c *Database_GetPreviousBountyByCreated_Call) RunAndReturn(run func(*http.Request) (uint, error)) *Database_GetPreviousBountyByCreated_Call { +func (_c *Database_GetWorkspaceBountiesCount_Call) RunAndReturn(run func(*http.Request, string) int64) *Database_GetWorkspaceBountiesCount_Call { _c.Call.Return(run) return _c } -// GetPreviousOrganizationBountyByCreated provides a mock function with given fields: r -func (_m *Database) GetPreviousOrganizationBountyByCreated(r *http.Request) (uint, error) { - ret := _m.Called(r) +// GetWorkspaceBountyCount provides a mock function with given fields: uuid +func (_m *Database) GetWorkspaceBountyCount(uuid string) int64 { + ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for GetPreviousOrganizationBountyByCreated") - } - - var r0 uint - var r1 error - if rf, ok := ret.Get(0).(func(*http.Request) (uint, error)); ok { - return rf(r) - } - if rf, ok := ret.Get(0).(func(*http.Request) uint); ok { - r0 = rf(r) - } else { - r0 = ret.Get(0).(uint) + panic("no return value specified for GetWorkspaceBountyCount") } - if rf, ok := ret.Get(1).(func(*http.Request) error); ok { - r1 = rf(r) + var r0 int64 + if rf, ok := ret.Get(0).(func(string) int64); ok { + r0 = rf(uuid) } else { - r1 = ret.Error(1) + r0 = ret.Get(0).(int64) } - return r0, r1 + return r0 } -// Database_GetPreviousOrganizationBountyByCreated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPreviousOrganizationBountyByCreated' -type Database_GetPreviousOrganizationBountyByCreated_Call struct { +// Database_GetWorkspaceBountyCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBountyCount' +type Database_GetWorkspaceBountyCount_Call struct { *mock.Call } -// GetPreviousOrganizationBountyByCreated is a helper method to define mock.On call -// - r *http.Request -func (_e *Database_Expecter) GetPreviousOrganizationBountyByCreated(r interface{}) *Database_GetPreviousOrganizationBountyByCreated_Call { - return &Database_GetPreviousOrganizationBountyByCreated_Call{Call: _e.mock.On("GetPreviousOrganizationBountyByCreated", r)} +// GetWorkspaceBountyCount is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetWorkspaceBountyCount(uuid interface{}) *Database_GetWorkspaceBountyCount_Call { + return &Database_GetWorkspaceBountyCount_Call{Call: _e.mock.On("GetWorkspaceBountyCount", uuid)} } -func (_c *Database_GetPreviousOrganizationBountyByCreated_Call) Run(run func(r *http.Request)) *Database_GetPreviousOrganizationBountyByCreated_Call { +func (_c *Database_GetWorkspaceBountyCount_Call) Run(run func(uuid string)) *Database_GetWorkspaceBountyCount_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*http.Request)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetPreviousOrganizationBountyByCreated_Call) Return(_a0 uint, _a1 error) *Database_GetPreviousOrganizationBountyByCreated_Call { - _c.Call.Return(_a0, _a1) +func (_c *Database_GetWorkspaceBountyCount_Call) Return(_a0 int64) *Database_GetWorkspaceBountyCount_Call { + _c.Call.Return(_a0) return _c } -func (_c *Database_GetPreviousOrganizationBountyByCreated_Call) RunAndReturn(run func(*http.Request) (uint, error)) *Database_GetPreviousOrganizationBountyByCreated_Call { +func (_c *Database_GetWorkspaceBountyCount_Call) RunAndReturn(run func(string) int64) *Database_GetWorkspaceBountyCount_Call { _c.Call.Return(run) return _c } -// GetTribe provides a mock function with given fields: uuid -func (_m *Database) GetTribe(uuid string) db.Tribe { - ret := _m.Called(uuid) +// GetWorkspaceBudget provides a mock function with given fields: org_uuid +func (_m *Database) GetWorkspaceBudget(org_uuid string) db.BountyBudget { + ret := _m.Called(org_uuid) if len(ret) == 0 { - panic("no return value specified for GetTribe") + panic("no return value specified for GetWorkspaceBudget") } - var r0 db.Tribe - if rf, ok := ret.Get(0).(func(string) db.Tribe); ok { - r0 = rf(uuid) + var r0 db.BountyBudget + if rf, ok := ret.Get(0).(func(string) db.BountyBudget); ok { + r0 = rf(org_uuid) } else { - r0 = ret.Get(0).(db.Tribe) + r0 = ret.Get(0).(db.BountyBudget) } return r0 } -// Database_GetTribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribe' -type Database_GetTribe_Call struct { +// Database_GetWorkspaceBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBudget' +type Database_GetWorkspaceBudget_Call struct { *mock.Call } -// GetTribe is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) GetTribe(uuid interface{}) *Database_GetTribe_Call { - return &Database_GetTribe_Call{Call: _e.mock.On("GetTribe", uuid)} +// GetWorkspaceBudget is a helper method to define mock.On call +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceBudget(org_uuid interface{}) *Database_GetWorkspaceBudget_Call { + return &Database_GetWorkspaceBudget_Call{Call: _e.mock.On("GetWorkspaceBudget", org_uuid)} } -func (_c *Database_GetTribe_Call) Run(run func(uuid string)) *Database_GetTribe_Call { +func (_c *Database_GetWorkspaceBudget_Call) Run(run func(org_uuid string)) *Database_GetWorkspaceBudget_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetTribe_Call) Return(_a0 db.Tribe) *Database_GetTribe_Call { +func (_c *Database_GetWorkspaceBudget_Call) Return(_a0 db.BountyBudget) *Database_GetWorkspaceBudget_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetTribe_Call) RunAndReturn(run func(string) db.Tribe) *Database_GetTribe_Call { +func (_c *Database_GetWorkspaceBudget_Call) RunAndReturn(run func(string) db.BountyBudget) *Database_GetWorkspaceBudget_Call { _c.Call.Return(run) return _c } -// GetTribeByIdAndPubkey provides a mock function with given fields: uuid, pubkey -func (_m *Database) GetTribeByIdAndPubkey(uuid string, pubkey string) db.Tribe { - ret := _m.Called(uuid, pubkey) +// GetWorkspaceBudgetHistory provides a mock function with given fields: org_uuid +func (_m *Database) GetWorkspaceBudgetHistory(org_uuid string) []db.BudgetHistoryData { + ret := _m.Called(org_uuid) if len(ret) == 0 { - panic("no return value specified for GetTribeByIdAndPubkey") + panic("no return value specified for GetWorkspaceBudgetHistory") } - var r0 db.Tribe - if rf, ok := ret.Get(0).(func(string, string) db.Tribe); ok { - r0 = rf(uuid, pubkey) + var r0 []db.BudgetHistoryData + if rf, ok := ret.Get(0).(func(string) []db.BudgetHistoryData); ok { + r0 = rf(org_uuid) } else { - r0 = ret.Get(0).(db.Tribe) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.BudgetHistoryData) + } } return r0 } -// Database_GetTribeByIdAndPubkey_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribeByIdAndPubkey' -type Database_GetTribeByIdAndPubkey_Call struct { +// Database_GetWorkspaceBudgetHistory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceBudgetHistory' +type Database_GetWorkspaceBudgetHistory_Call struct { *mock.Call } -// GetTribeByIdAndPubkey is a helper method to define mock.On call -// - uuid string -// - pubkey string -func (_e *Database_Expecter) GetTribeByIdAndPubkey(uuid interface{}, pubkey interface{}) *Database_GetTribeByIdAndPubkey_Call { - return &Database_GetTribeByIdAndPubkey_Call{Call: _e.mock.On("GetTribeByIdAndPubkey", uuid, pubkey)} +// GetWorkspaceBudgetHistory is a helper method to define mock.On call +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceBudgetHistory(org_uuid interface{}) *Database_GetWorkspaceBudgetHistory_Call { + return &Database_GetWorkspaceBudgetHistory_Call{Call: _e.mock.On("GetWorkspaceBudgetHistory", org_uuid)} } -func (_c *Database_GetTribeByIdAndPubkey_Call) Run(run func(uuid string, pubkey string)) *Database_GetTribeByIdAndPubkey_Call { +func (_c *Database_GetWorkspaceBudgetHistory_Call) Run(run func(org_uuid string)) *Database_GetWorkspaceBudgetHistory_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetTribeByIdAndPubkey_Call) Return(_a0 db.Tribe) *Database_GetTribeByIdAndPubkey_Call { +func (_c *Database_GetWorkspaceBudgetHistory_Call) Return(_a0 []db.BudgetHistoryData) *Database_GetWorkspaceBudgetHistory_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetTribeByIdAndPubkey_Call) RunAndReturn(run func(string, string) db.Tribe) *Database_GetTribeByIdAndPubkey_Call { +func (_c *Database_GetWorkspaceBudgetHistory_Call) RunAndReturn(run func(string) []db.BudgetHistoryData) *Database_GetWorkspaceBudgetHistory_Call { _c.Call.Return(run) return _c } -// GetTribeByUniqueName provides a mock function with given fields: un -func (_m *Database) GetTribeByUniqueName(un string) db.Tribe { - ret := _m.Called(un) +// GetWorkspaceByName provides a mock function with given fields: name +func (_m *Database) GetWorkspaceByName(name string) db.Organization { + ret := _m.Called(name) if len(ret) == 0 { - panic("no return value specified for GetTribeByUniqueName") + panic("no return value specified for GetWorkspaceByName") } - var r0 db.Tribe - if rf, ok := ret.Get(0).(func(string) db.Tribe); ok { - r0 = rf(un) + var r0 db.Organization + if rf, ok := ret.Get(0).(func(string) db.Organization); ok { + r0 = rf(name) } else { - r0 = ret.Get(0).(db.Tribe) + r0 = ret.Get(0).(db.Organization) } return r0 } -// Database_GetTribeByUniqueName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribeByUniqueName' -type Database_GetTribeByUniqueName_Call struct { +// Database_GetWorkspaceByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceByName' +type Database_GetWorkspaceByName_Call struct { *mock.Call } -// GetTribeByUniqueName is a helper method to define mock.On call -// - un string -func (_e *Database_Expecter) GetTribeByUniqueName(un interface{}) *Database_GetTribeByUniqueName_Call { - return &Database_GetTribeByUniqueName_Call{Call: _e.mock.On("GetTribeByUniqueName", un)} +// GetWorkspaceByName is a helper method to define mock.On call +// - name string +func (_e *Database_Expecter) GetWorkspaceByName(name interface{}) *Database_GetWorkspaceByName_Call { + return &Database_GetWorkspaceByName_Call{Call: _e.mock.On("GetWorkspaceByName", name)} } -func (_c *Database_GetTribeByUniqueName_Call) Run(run func(un string)) *Database_GetTribeByUniqueName_Call { +func (_c *Database_GetWorkspaceByName_Call) Run(run func(name string)) *Database_GetWorkspaceByName_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetTribeByUniqueName_Call) Return(_a0 db.Tribe) *Database_GetTribeByUniqueName_Call { +func (_c *Database_GetWorkspaceByName_Call) Return(_a0 db.Organization) *Database_GetWorkspaceByName_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetTribeByUniqueName_Call) RunAndReturn(run func(string) db.Tribe) *Database_GetTribeByUniqueName_Call { +func (_c *Database_GetWorkspaceByName_Call) RunAndReturn(run func(string) db.Organization) *Database_GetWorkspaceByName_Call { _c.Call.Return(run) return _c } -// GetTribesByAppUrl provides a mock function with given fields: aurl -func (_m *Database) GetTribesByAppUrl(aurl string) []db.Tribe { - ret := _m.Called(aurl) +// GetWorkspaceByUuid provides a mock function with given fields: uuid +func (_m *Database) GetWorkspaceByUuid(uuid string) db.Organization { + ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for GetTribesByAppUrl") + panic("no return value specified for GetWorkspaceByUuid") } - var r0 []db.Tribe - if rf, ok := ret.Get(0).(func(string) []db.Tribe); ok { - r0 = rf(aurl) + var r0 db.Organization + if rf, ok := ret.Get(0).(func(string) db.Organization); ok { + r0 = rf(uuid) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Tribe) - } + r0 = ret.Get(0).(db.Organization) } return r0 } -// Database_GetTribesByAppUrl_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribesByAppUrl' -type Database_GetTribesByAppUrl_Call struct { +// Database_GetWorkspaceByUuid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceByUuid' +type Database_GetWorkspaceByUuid_Call struct { *mock.Call } -// GetTribesByAppUrl is a helper method to define mock.On call -// - aurl string -func (_e *Database_Expecter) GetTribesByAppUrl(aurl interface{}) *Database_GetTribesByAppUrl_Call { - return &Database_GetTribesByAppUrl_Call{Call: _e.mock.On("GetTribesByAppUrl", aurl)} +// GetWorkspaceByUuid is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetWorkspaceByUuid(uuid interface{}) *Database_GetWorkspaceByUuid_Call { + return &Database_GetWorkspaceByUuid_Call{Call: _e.mock.On("GetWorkspaceByUuid", uuid)} } -func (_c *Database_GetTribesByAppUrl_Call) Run(run func(aurl string)) *Database_GetTribesByAppUrl_Call { +func (_c *Database_GetWorkspaceByUuid_Call) Run(run func(uuid string)) *Database_GetWorkspaceByUuid_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetTribesByAppUrl_Call) Return(_a0 []db.Tribe) *Database_GetTribesByAppUrl_Call { +func (_c *Database_GetWorkspaceByUuid_Call) Return(_a0 db.Organization) *Database_GetWorkspaceByUuid_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetTribesByAppUrl_Call) RunAndReturn(run func(string) []db.Tribe) *Database_GetTribesByAppUrl_Call { +func (_c *Database_GetWorkspaceByUuid_Call) RunAndReturn(run func(string) db.Organization) *Database_GetWorkspaceByUuid_Call { _c.Call.Return(run) return _c } -// GetTribesByOwner provides a mock function with given fields: pubkey -func (_m *Database) GetTribesByOwner(pubkey string) []db.Tribe { - ret := _m.Called(pubkey) +// GetWorkspaceInvoices provides a mock function with given fields: org_uuid +func (_m *Database) GetWorkspaceInvoices(org_uuid string) []db.InvoiceList { + ret := _m.Called(org_uuid) if len(ret) == 0 { - panic("no return value specified for GetTribesByOwner") + panic("no return value specified for GetWorkspaceInvoices") } - var r0 []db.Tribe - if rf, ok := ret.Get(0).(func(string) []db.Tribe); ok { - r0 = rf(pubkey) + var r0 []db.InvoiceList + if rf, ok := ret.Get(0).(func(string) []db.InvoiceList); ok { + r0 = rf(org_uuid) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Tribe) + r0 = ret.Get(0).([]db.InvoiceList) } } return r0 } -// Database_GetTribesByOwner_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribesByOwner' -type Database_GetTribesByOwner_Call struct { +// Database_GetWorkspaceInvoices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceInvoices' +type Database_GetWorkspaceInvoices_Call struct { *mock.Call } -// GetTribesByOwner is a helper method to define mock.On call -// - pubkey string -func (_e *Database_Expecter) GetTribesByOwner(pubkey interface{}) *Database_GetTribesByOwner_Call { - return &Database_GetTribesByOwner_Call{Call: _e.mock.On("GetTribesByOwner", pubkey)} +// GetWorkspaceInvoices is a helper method to define mock.On call +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceInvoices(org_uuid interface{}) *Database_GetWorkspaceInvoices_Call { + return &Database_GetWorkspaceInvoices_Call{Call: _e.mock.On("GetWorkspaceInvoices", org_uuid)} } -func (_c *Database_GetTribesByOwner_Call) Run(run func(pubkey string)) *Database_GetTribesByOwner_Call { +func (_c *Database_GetWorkspaceInvoices_Call) Run(run func(org_uuid string)) *Database_GetWorkspaceInvoices_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetTribesByOwner_Call) Return(_a0 []db.Tribe) *Database_GetTribesByOwner_Call { +func (_c *Database_GetWorkspaceInvoices_Call) Return(_a0 []db.InvoiceList) *Database_GetWorkspaceInvoices_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetTribesByOwner_Call) RunAndReturn(run func(string) []db.Tribe) *Database_GetTribesByOwner_Call { +func (_c *Database_GetWorkspaceInvoices_Call) RunAndReturn(run func(string) []db.InvoiceList) *Database_GetWorkspaceInvoices_Call { _c.Call.Return(run) return _c } -// GetTribesTotal provides a mock function with given fields: -func (_m *Database) GetTribesTotal() int64 { - ret := _m.Called() +// GetWorkspaceInvoicesCount provides a mock function with given fields: org_uuid +func (_m *Database) GetWorkspaceInvoicesCount(org_uuid string) int64 { + ret := _m.Called(org_uuid) if len(ret) == 0 { - panic("no return value specified for GetTribesTotal") + panic("no return value specified for GetWorkspaceInvoicesCount") } var r0 int64 - if rf, ok := ret.Get(0).(func() int64); ok { - r0 = rf() + if rf, ok := ret.Get(0).(func(string) int64); ok { + r0 = rf(org_uuid) } else { r0 = ret.Get(0).(int64) } @@ -4725,186 +4717,196 @@ func (_m *Database) GetTribesTotal() int64 { return r0 } -// Database_GetTribesTotal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTribesTotal' -type Database_GetTribesTotal_Call struct { +// Database_GetWorkspaceInvoicesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceInvoicesCount' +type Database_GetWorkspaceInvoicesCount_Call struct { *mock.Call } -// GetTribesTotal is a helper method to define mock.On call -func (_e *Database_Expecter) GetTribesTotal() *Database_GetTribesTotal_Call { - return &Database_GetTribesTotal_Call{Call: _e.mock.On("GetTribesTotal")} +// GetWorkspaceInvoicesCount is a helper method to define mock.On call +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceInvoicesCount(org_uuid interface{}) *Database_GetWorkspaceInvoicesCount_Call { + return &Database_GetWorkspaceInvoicesCount_Call{Call: _e.mock.On("GetWorkspaceInvoicesCount", org_uuid)} } -func (_c *Database_GetTribesTotal_Call) Run(run func()) *Database_GetTribesTotal_Call { +func (_c *Database_GetWorkspaceInvoicesCount_Call) Run(run func(org_uuid string)) *Database_GetWorkspaceInvoicesCount_Call { _c.Call.Run(func(args mock.Arguments) { - run() + run(args[0].(string)) }) return _c } -func (_c *Database_GetTribesTotal_Call) Return(_a0 int64) *Database_GetTribesTotal_Call { +func (_c *Database_GetWorkspaceInvoicesCount_Call) Return(_a0 int64) *Database_GetWorkspaceInvoicesCount_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetTribesTotal_Call) RunAndReturn(run func() int64) *Database_GetTribesTotal_Call { +func (_c *Database_GetWorkspaceInvoicesCount_Call) RunAndReturn(run func(string) int64) *Database_GetWorkspaceInvoicesCount_Call { _c.Call.Return(run) return _c } -// GetUnconfirmedGithub provides a mock function with given fields: -func (_m *Database) GetUnconfirmedGithub() []db.Person { - ret := _m.Called() +// GetWorkspaceStatusBudget provides a mock function with given fields: org_uuid +func (_m *Database) GetWorkspaceStatusBudget(org_uuid string) db.StatusBudget { + ret := _m.Called(org_uuid) if len(ret) == 0 { - panic("no return value specified for GetUnconfirmedGithub") + panic("no return value specified for GetWorkspaceStatusBudget") } - var r0 []db.Person - if rf, ok := ret.Get(0).(func() []db.Person); ok { - r0 = rf() + var r0 db.StatusBudget + if rf, ok := ret.Get(0).(func(string) db.StatusBudget); ok { + r0 = rf(org_uuid) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Person) - } + r0 = ret.Get(0).(db.StatusBudget) } return r0 } -// Database_GetUnconfirmedGithub_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUnconfirmedGithub' -type Database_GetUnconfirmedGithub_Call struct { +// Database_GetWorkspaceStatusBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceStatusBudget' +type Database_GetWorkspaceStatusBudget_Call struct { *mock.Call } - -// GetUnconfirmedGithub is a helper method to define mock.On call -func (_e *Database_Expecter) GetUnconfirmedGithub() *Database_GetUnconfirmedGithub_Call { - return &Database_GetUnconfirmedGithub_Call{Call: _e.mock.On("GetUnconfirmedGithub")} + +// GetWorkspaceStatusBudget is a helper method to define mock.On call +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceStatusBudget(org_uuid interface{}) *Database_GetWorkspaceStatusBudget_Call { + return &Database_GetWorkspaceStatusBudget_Call{Call: _e.mock.On("GetWorkspaceStatusBudget", org_uuid)} } -func (_c *Database_GetUnconfirmedGithub_Call) Run(run func()) *Database_GetUnconfirmedGithub_Call { +func (_c *Database_GetWorkspaceStatusBudget_Call) Run(run func(org_uuid string)) *Database_GetWorkspaceStatusBudget_Call { _c.Call.Run(func(args mock.Arguments) { - run() + run(args[0].(string)) }) return _c } -func (_c *Database_GetUnconfirmedGithub_Call) Return(_a0 []db.Person) *Database_GetUnconfirmedGithub_Call { +func (_c *Database_GetWorkspaceStatusBudget_Call) Return(_a0 db.StatusBudget) *Database_GetWorkspaceStatusBudget_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetUnconfirmedGithub_Call) RunAndReturn(run func() []db.Person) *Database_GetUnconfirmedGithub_Call { +func (_c *Database_GetWorkspaceStatusBudget_Call) RunAndReturn(run func(string) db.StatusBudget) *Database_GetWorkspaceStatusBudget_Call { _c.Call.Return(run) return _c } -// GetUnconfirmedTwitter provides a mock function with given fields: -func (_m *Database) GetUnconfirmedTwitter() []db.Person { - ret := _m.Called() +// GetWorkspaceUser provides a mock function with given fields: pubkey, org_uuid +func (_m *Database) GetWorkspaceUser(pubkey string, org_uuid string) db.OrganizationUsers { + ret := _m.Called(pubkey, org_uuid) if len(ret) == 0 { - panic("no return value specified for GetUnconfirmedTwitter") + panic("no return value specified for GetWorkspaceUser") } - var r0 []db.Person - if rf, ok := ret.Get(0).(func() []db.Person); ok { - r0 = rf() + var r0 db.OrganizationUsers + if rf, ok := ret.Get(0).(func(string, string) db.OrganizationUsers); ok { + r0 = rf(pubkey, org_uuid) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Person) - } + r0 = ret.Get(0).(db.OrganizationUsers) } return r0 } -// Database_GetUnconfirmedTwitter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUnconfirmedTwitter' -type Database_GetUnconfirmedTwitter_Call struct { +// Database_GetWorkspaceUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceUser' +type Database_GetWorkspaceUser_Call struct { *mock.Call } -// GetUnconfirmedTwitter is a helper method to define mock.On call -func (_e *Database_Expecter) GetUnconfirmedTwitter() *Database_GetUnconfirmedTwitter_Call { - return &Database_GetUnconfirmedTwitter_Call{Call: _e.mock.On("GetUnconfirmedTwitter")} +// GetWorkspaceUser is a helper method to define mock.On call +// - pubkey string +// - org_uuid string +func (_e *Database_Expecter) GetWorkspaceUser(pubkey interface{}, org_uuid interface{}) *Database_GetWorkspaceUser_Call { + return &Database_GetWorkspaceUser_Call{Call: _e.mock.On("GetWorkspaceUser", pubkey, org_uuid)} } -func (_c *Database_GetUnconfirmedTwitter_Call) Run(run func()) *Database_GetUnconfirmedTwitter_Call { +func (_c *Database_GetWorkspaceUser_Call) Run(run func(pubkey string, org_uuid string)) *Database_GetWorkspaceUser_Call { _c.Call.Run(func(args mock.Arguments) { - run() + run(args[0].(string), args[1].(string)) }) return _c } -func (_c *Database_GetUnconfirmedTwitter_Call) Return(_a0 []db.Person) *Database_GetUnconfirmedTwitter_Call { +func (_c *Database_GetWorkspaceUser_Call) Return(_a0 db.OrganizationUsers) *Database_GetWorkspaceUser_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetUnconfirmedTwitter_Call) RunAndReturn(run func() []db.Person) *Database_GetUnconfirmedTwitter_Call { +func (_c *Database_GetWorkspaceUser_Call) RunAndReturn(run func(string, string) db.OrganizationUsers) *Database_GetWorkspaceUser_Call { _c.Call.Return(run) return _c } -// GetUserAssignedOrganizations provides a mock function with given fields: pubkey -func (_m *Database) GetUserAssignedOrganizations(pubkey string) []db.OrganizationUsers { - ret := _m.Called(pubkey) +// GetWorkspaceUsers provides a mock function with given fields: uuid +func (_m *Database) GetWorkspaceUsers(uuid string) ([]db.OrganizationUsersData, error) { + ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for GetUserAssignedOrganizations") + panic("no return value specified for GetWorkspaceUsers") } - var r0 []db.OrganizationUsers - if rf, ok := ret.Get(0).(func(string) []db.OrganizationUsers); ok { - r0 = rf(pubkey) + var r0 []db.OrganizationUsersData + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]db.OrganizationUsersData, error)); ok { + return rf(uuid) + } + if rf, ok := ret.Get(0).(func(string) []db.OrganizationUsersData); ok { + r0 = rf(uuid) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.OrganizationUsers) + r0 = ret.Get(0).([]db.OrganizationUsersData) } } - return r0 + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(uuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 } -// Database_GetUserAssignedOrganizations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserAssignedOrganizations' -type Database_GetUserAssignedOrganizations_Call struct { +// Database_GetWorkspaceUsers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceUsers' +type Database_GetWorkspaceUsers_Call struct { *mock.Call } -// GetUserAssignedOrganizations is a helper method to define mock.On call -// - pubkey string -func (_e *Database_Expecter) GetUserAssignedOrganizations(pubkey interface{}) *Database_GetUserAssignedOrganizations_Call { - return &Database_GetUserAssignedOrganizations_Call{Call: _e.mock.On("GetUserAssignedOrganizations", pubkey)} +// GetWorkspaceUsers is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetWorkspaceUsers(uuid interface{}) *Database_GetWorkspaceUsers_Call { + return &Database_GetWorkspaceUsers_Call{Call: _e.mock.On("GetWorkspaceUsers", uuid)} } -func (_c *Database_GetUserAssignedOrganizations_Call) Run(run func(pubkey string)) *Database_GetUserAssignedOrganizations_Call { +func (_c *Database_GetWorkspaceUsers_Call) Run(run func(uuid string)) *Database_GetWorkspaceUsers_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(string)) }) return _c } -func (_c *Database_GetUserAssignedOrganizations_Call) Return(_a0 []db.OrganizationUsers) *Database_GetUserAssignedOrganizations_Call { - _c.Call.Return(_a0) +func (_c *Database_GetWorkspaceUsers_Call) Return(_a0 []db.OrganizationUsersData, _a1 error) *Database_GetWorkspaceUsers_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetUserAssignedOrganizations_Call) RunAndReturn(run func(string) []db.OrganizationUsers) *Database_GetUserAssignedOrganizations_Call { +func (_c *Database_GetWorkspaceUsers_Call) RunAndReturn(run func(string) ([]db.OrganizationUsersData, error)) *Database_GetWorkspaceUsers_Call { _c.Call.Return(run) return _c } -// GetUserBountiesCount provides a mock function with given fields: personKey, tabType -func (_m *Database) GetUserBountiesCount(personKey string, tabType string) int64 { - ret := _m.Called(personKey, tabType) +// GetWorkspaceUsersCount provides a mock function with given fields: uuid +func (_m *Database) GetWorkspaceUsersCount(uuid string) int64 { + ret := _m.Called(uuid) if len(ret) == 0 { - panic("no return value specified for GetUserBountiesCount") + panic("no return value specified for GetWorkspaceUsersCount") } var r0 int64 - if rf, ok := ret.Get(0).(func(string, string) int64); ok { - r0 = rf(personKey, tabType) + if rf, ok := ret.Get(0).(func(string) int64); ok { + r0 = rf(uuid) } else { r0 = ret.Get(0).(int64) } @@ -4912,46 +4914,45 @@ func (_m *Database) GetUserBountiesCount(personKey string, tabType string) int64 return r0 } -// Database_GetUserBountiesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserBountiesCount' -type Database_GetUserBountiesCount_Call struct { +// Database_GetWorkspaceUsersCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceUsersCount' +type Database_GetWorkspaceUsersCount_Call struct { *mock.Call } -// GetUserBountiesCount is a helper method to define mock.On call -// - personKey string -// - tabType string -func (_e *Database_Expecter) GetUserBountiesCount(personKey interface{}, tabType interface{}) *Database_GetUserBountiesCount_Call { - return &Database_GetUserBountiesCount_Call{Call: _e.mock.On("GetUserBountiesCount", personKey, tabType)} +// GetWorkspaceUsersCount is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetWorkspaceUsersCount(uuid interface{}) *Database_GetWorkspaceUsersCount_Call { + return &Database_GetWorkspaceUsersCount_Call{Call: _e.mock.On("GetWorkspaceUsersCount", uuid)} } -func (_c *Database_GetUserBountiesCount_Call) Run(run func(personKey string, tabType string)) *Database_GetUserBountiesCount_Call { +func (_c *Database_GetWorkspaceUsersCount_Call) Run(run func(uuid string)) *Database_GetWorkspaceUsersCount_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string)) + run(args[0].(string)) }) return _c } -func (_c *Database_GetUserBountiesCount_Call) Return(_a0 int64) *Database_GetUserBountiesCount_Call { +func (_c *Database_GetWorkspaceUsersCount_Call) Return(_a0 int64) *Database_GetWorkspaceUsersCount_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetUserBountiesCount_Call) RunAndReturn(run func(string, string) int64) *Database_GetUserBountiesCount_Call { +func (_c *Database_GetWorkspaceUsersCount_Call) RunAndReturn(run func(string) int64) *Database_GetWorkspaceUsersCount_Call { _c.Call.Return(run) return _c } -// GetUserCreatedOrganizations provides a mock function with given fields: pubkey -func (_m *Database) GetUserCreatedOrganizations(pubkey string) []db.Organization { - ret := _m.Called(pubkey) +// GetWorkspaces provides a mock function with given fields: r +func (_m *Database) GetWorkspaces(r *http.Request) []db.Organization { + ret := _m.Called(r) if len(ret) == 0 { - panic("no return value specified for GetUserCreatedOrganizations") + panic("no return value specified for GetWorkspaces") } var r0 []db.Organization - if rf, ok := ret.Get(0).(func(string) []db.Organization); ok { - r0 = rf(pubkey) + if rf, ok := ret.Get(0).(func(*http.Request) []db.Organization); ok { + r0 = rf(r) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]db.Organization) @@ -4961,76 +4962,75 @@ func (_m *Database) GetUserCreatedOrganizations(pubkey string) []db.Organization return r0 } -// Database_GetUserCreatedOrganizations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserCreatedOrganizations' -type Database_GetUserCreatedOrganizations_Call struct { +// Database_GetWorkspaces_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaces' +type Database_GetWorkspaces_Call struct { *mock.Call } -// GetUserCreatedOrganizations is a helper method to define mock.On call -// - pubkey string -func (_e *Database_Expecter) GetUserCreatedOrganizations(pubkey interface{}) *Database_GetUserCreatedOrganizations_Call { - return &Database_GetUserCreatedOrganizations_Call{Call: _e.mock.On("GetUserCreatedOrganizations", pubkey)} +// GetWorkspaces is a helper method to define mock.On call +// - r *http.Request +func (_e *Database_Expecter) GetWorkspaces(r interface{}) *Database_GetWorkspaces_Call { + return &Database_GetWorkspaces_Call{Call: _e.mock.On("GetWorkspaces", r)} } -func (_c *Database_GetUserCreatedOrganizations_Call) Run(run func(pubkey string)) *Database_GetUserCreatedOrganizations_Call { +func (_c *Database_GetWorkspaces_Call) Run(run func(r *http.Request)) *Database_GetWorkspaces_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(*http.Request)) }) return _c } -func (_c *Database_GetUserCreatedOrganizations_Call) Return(_a0 []db.Organization) *Database_GetUserCreatedOrganizations_Call { +func (_c *Database_GetWorkspaces_Call) Return(_a0 []db.Organization) *Database_GetWorkspaces_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetUserCreatedOrganizations_Call) RunAndReturn(run func(string) []db.Organization) *Database_GetUserCreatedOrganizations_Call { +func (_c *Database_GetWorkspaces_Call) RunAndReturn(run func(*http.Request) []db.Organization) *Database_GetWorkspaces_Call { _c.Call.Return(run) return _c } -// GetUserInvoiceData provides a mock function with given fields: payment_request -func (_m *Database) GetUserInvoiceData(payment_request string) db.UserInvoiceData { - ret := _m.Called(payment_request) +// GetWorkspacesCount provides a mock function with given fields: +func (_m *Database) GetWorkspacesCount() int64 { + ret := _m.Called() if len(ret) == 0 { - panic("no return value specified for GetUserInvoiceData") + panic("no return value specified for GetWorkspacesCount") } - var r0 db.UserInvoiceData - if rf, ok := ret.Get(0).(func(string) db.UserInvoiceData); ok { - r0 = rf(payment_request) + var r0 int64 + if rf, ok := ret.Get(0).(func() int64); ok { + r0 = rf() } else { - r0 = ret.Get(0).(db.UserInvoiceData) + r0 = ret.Get(0).(int64) } return r0 } -// Database_GetUserInvoiceData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserInvoiceData' -type Database_GetUserInvoiceData_Call struct { +// Database_GetWorkspacesCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspacesCount' +type Database_GetWorkspacesCount_Call struct { *mock.Call } -// GetUserInvoiceData is a helper method to define mock.On call -// - payment_request string -func (_e *Database_Expecter) GetUserInvoiceData(payment_request interface{}) *Database_GetUserInvoiceData_Call { - return &Database_GetUserInvoiceData_Call{Call: _e.mock.On("GetUserInvoiceData", payment_request)} +// GetWorkspacesCount is a helper method to define mock.On call +func (_e *Database_Expecter) GetWorkspacesCount() *Database_GetWorkspacesCount_Call { + return &Database_GetWorkspacesCount_Call{Call: _e.mock.On("GetWorkspacesCount")} } -func (_c *Database_GetUserInvoiceData_Call) Run(run func(payment_request string)) *Database_GetUserInvoiceData_Call { +func (_c *Database_GetWorkspacesCount_Call) Run(run func()) *Database_GetWorkspacesCount_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run() }) return _c } -func (_c *Database_GetUserInvoiceData_Call) Return(_a0 db.UserInvoiceData) *Database_GetUserInvoiceData_Call { +func (_c *Database_GetWorkspacesCount_Call) Return(_a0 int64) *Database_GetWorkspacesCount_Call { _c.Call.Return(_a0) return _c } -func (_c *Database_GetUserInvoiceData_Call) RunAndReturn(run func(string) db.UserInvoiceData) *Database_GetUserInvoiceData_Call { +func (_c *Database_GetWorkspacesCount_Call) RunAndReturn(run func() int64) *Database_GetWorkspacesCount_Call { _c.Call.Return(run) return _c } @@ -6056,98 +6056,6 @@ func (_c *Database_UpdateLeaderBoard_Call) RunAndReturn(run func(string, string, return _c } -// UpdateOrganizationBudget provides a mock function with given fields: budget -func (_m *Database) UpdateOrganizationBudget(budget db.BountyBudget) db.BountyBudget { - ret := _m.Called(budget) - - if len(ret) == 0 { - panic("no return value specified for UpdateOrganizationBudget") - } - - var r0 db.BountyBudget - if rf, ok := ret.Get(0).(func(db.BountyBudget) db.BountyBudget); ok { - r0 = rf(budget) - } else { - r0 = ret.Get(0).(db.BountyBudget) - } - - return r0 -} - -// Database_UpdateOrganizationBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateOrganizationBudget' -type Database_UpdateOrganizationBudget_Call struct { - *mock.Call -} - -// UpdateOrganizationBudget is a helper method to define mock.On call -// - budget db.BountyBudget -func (_e *Database_Expecter) UpdateOrganizationBudget(budget interface{}) *Database_UpdateOrganizationBudget_Call { - return &Database_UpdateOrganizationBudget_Call{Call: _e.mock.On("UpdateOrganizationBudget", budget)} -} - -func (_c *Database_UpdateOrganizationBudget_Call) Run(run func(budget db.BountyBudget)) *Database_UpdateOrganizationBudget_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.BountyBudget)) - }) - return _c -} - -func (_c *Database_UpdateOrganizationBudget_Call) Return(_a0 db.BountyBudget) *Database_UpdateOrganizationBudget_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Database_UpdateOrganizationBudget_Call) RunAndReturn(run func(db.BountyBudget) db.BountyBudget) *Database_UpdateOrganizationBudget_Call { - _c.Call.Return(run) - return _c -} - -// UpdateOrganizationForDeletion provides a mock function with given fields: uuid -func (_m *Database) UpdateOrganizationForDeletion(uuid string) error { - ret := _m.Called(uuid) - - if len(ret) == 0 { - panic("no return value specified for UpdateOrganizationForDeletion") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string) error); ok { - r0 = rf(uuid) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Database_UpdateOrganizationForDeletion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateOrganizationForDeletion' -type Database_UpdateOrganizationForDeletion_Call struct { - *mock.Call -} - -// UpdateOrganizationForDeletion is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) UpdateOrganizationForDeletion(uuid interface{}) *Database_UpdateOrganizationForDeletion_Call { - return &Database_UpdateOrganizationForDeletion_Call{Call: _e.mock.On("UpdateOrganizationForDeletion", uuid)} -} - -func (_c *Database_UpdateOrganizationForDeletion_Call) Run(run func(uuid string)) *Database_UpdateOrganizationForDeletion_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *Database_UpdateOrganizationForDeletion_Call) Return(_a0 error) *Database_UpdateOrganizationForDeletion_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Database_UpdateOrganizationForDeletion_Call) RunAndReturn(run func(string) error) *Database_UpdateOrganizationForDeletion_Call { - _c.Call.Return(run) - return _c -} - // UpdatePerson provides a mock function with given fields: id, u func (_m *Database) UpdatePerson(id uint, u map[string]interface{}) bool { ret := _m.Called(id, u) @@ -6310,6 +6218,98 @@ func (_c *Database_UpdateTwitterConfirmed_Call) RunAndReturn(run func(uint, bool return _c } +// UpdateWorkspaceBudget provides a mock function with given fields: budget +func (_m *Database) UpdateWorkspaceBudget(budget db.BountyBudget) db.BountyBudget { + ret := _m.Called(budget) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkspaceBudget") + } + + var r0 db.BountyBudget + if rf, ok := ret.Get(0).(func(db.BountyBudget) db.BountyBudget); ok { + r0 = rf(budget) + } else { + r0 = ret.Get(0).(db.BountyBudget) + } + + return r0 +} + +// Database_UpdateWorkspaceBudget_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWorkspaceBudget' +type Database_UpdateWorkspaceBudget_Call struct { + *mock.Call +} + +// UpdateWorkspaceBudget is a helper method to define mock.On call +// - budget db.BountyBudget +func (_e *Database_Expecter) UpdateWorkspaceBudget(budget interface{}) *Database_UpdateWorkspaceBudget_Call { + return &Database_UpdateWorkspaceBudget_Call{Call: _e.mock.On("UpdateWorkspaceBudget", budget)} +} + +func (_c *Database_UpdateWorkspaceBudget_Call) Run(run func(budget db.BountyBudget)) *Database_UpdateWorkspaceBudget_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(db.BountyBudget)) + }) + return _c +} + +func (_c *Database_UpdateWorkspaceBudget_Call) Return(_a0 db.BountyBudget) *Database_UpdateWorkspaceBudget_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_UpdateWorkspaceBudget_Call) RunAndReturn(run func(db.BountyBudget) db.BountyBudget) *Database_UpdateWorkspaceBudget_Call { + _c.Call.Return(run) + return _c +} + +// UpdateWorkspaceForDeletion provides a mock function with given fields: uuid +func (_m *Database) UpdateWorkspaceForDeletion(uuid string) error { + ret := _m.Called(uuid) + + if len(ret) == 0 { + panic("no return value specified for UpdateWorkspaceForDeletion") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string) error); ok { + r0 = rf(uuid) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_UpdateWorkspaceForDeletion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateWorkspaceForDeletion' +type Database_UpdateWorkspaceForDeletion_Call struct { + *mock.Call +} + +// UpdateWorkspaceForDeletion is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) UpdateWorkspaceForDeletion(uuid interface{}) *Database_UpdateWorkspaceForDeletion_Call { + return &Database_UpdateWorkspaceForDeletion_Call{Call: _e.mock.On("UpdateWorkspaceForDeletion", uuid)} +} + +func (_c *Database_UpdateWorkspaceForDeletion_Call) Run(run func(uuid string)) *Database_UpdateWorkspaceForDeletion_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_UpdateWorkspaceForDeletion_Call) Return(_a0 error) *Database_UpdateWorkspaceForDeletion_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_UpdateWorkspaceForDeletion_Call) RunAndReturn(run func(string) error) *Database_UpdateWorkspaceForDeletion_Call { + _c.Call.Return(run) + return _c +} + // UserHasAccess provides a mock function with given fields: pubKeyFromAuth, uuid, role func (_m *Database) UserHasAccess(pubKeyFromAuth string, uuid string, role string) bool { ret := _m.Called(pubKeyFromAuth, uuid, role) diff --git a/routes/bounty.go b/routes/bounty.go index 1158a6a8d..3d440c0e4 100644 --- a/routes/bounty.go +++ b/routes/bounty.go @@ -19,8 +19,8 @@ func BountyRoutes() chi.Router { r.Get("/index/{bountyId}", bountyHandler.GetBountyIndexById) r.Get("/next/{created}", bountyHandler.GetNextBountyByCreated) r.Get("/previous/{created}", bountyHandler.GetPreviousBountyByCreated) - r.Get("/org/next/{uuid}/{created}", bountyHandler.GetOrganizationNextBountyByCreated) - r.Get("/org/previous/{uuid}/{created}", bountyHandler.GetOrganizationPreviousBountyByCreated) + r.Get("/org/next/{uuid}/{created}", bountyHandler.GetWorkspaceNextBountyByCreated) + r.Get("/org/previous/{uuid}/{created}", bountyHandler.GetWorkspacePreviousBountyByCreated) r.Get("/created/{created}", bountyHandler.GetBountyByCreated) r.Get("/count/{personKey}/{tabType}", handlers.GetUserBountyCount) diff --git a/routes/index.go b/routes/index.go index 1615fa30e..98dc0c162 100644 --- a/routes/index.go +++ b/routes/index.go @@ -34,7 +34,7 @@ func NewRouter() *http.Server { r.Mount("/connectioncodes", ConnectionCodesRoutes()) r.Mount("/github_issue", GithubIssuesRoutes()) r.Mount("/gobounties", BountyRoutes()) - r.Mount("/organizations", OrganizationRoutes()) + r.Mount("/workspaces", WorkspaceRoutes()) r.Mount("/metrics", MetricsRoutes()) r.Group(func(r chi.Router) { diff --git a/routes/metrics.go b/routes/metrics.go index 53bc61257..e24a1386d 100644 --- a/routes/metrics.go +++ b/routes/metrics.go @@ -15,7 +15,7 @@ func MetricsRoutes() chi.Router { r.Post("/payment", handlers.PaymentMetrics) r.Post("/people", handlers.PeopleMetrics) - r.Post("/organization", handlers.OrganizationtMetrics) + r.Post("/organization", handlers.WorkspacetMetrics) r.Post("/bounty_stats", mh.BountyMetrics) r.Post("/bounties", mh.MetricsBounties) r.Post("/bounties/count", mh.MetricsBountiesCount) diff --git a/routes/organizations.go b/routes/organizations.go deleted file mode 100644 index 66041c99a..000000000 --- a/routes/organizations.go +++ /dev/null @@ -1,43 +0,0 @@ -package routes - -import ( - "github.com/go-chi/chi" - "github.com/stakwork/sphinx-tribes/auth" - "github.com/stakwork/sphinx-tribes/db" - "github.com/stakwork/sphinx-tribes/handlers" -) - -func OrganizationRoutes() chi.Router { - r := chi.NewRouter() - organizationHandlers := handlers.NewOrganizationHandler(db.DB) - r.Group(func(r chi.Router) { - r.Get("/", handlers.GetOrganizations) - r.Get("/count", handlers.GetOrganizationsCount) - r.Get("/{uuid}", handlers.GetOrganizationByUuid) - r.Get("/users/{uuid}", handlers.GetOrganizationUsers) - r.Get("/users/{uuid}/count", handlers.GetOrganizationUsersCount) - r.Get("/bounties/{uuid}", organizationHandlers.GetOrganizationBounties) - r.Get("/bounties/{uuid}/count", organizationHandlers.GetOrganizationBountiesCount) - r.Get("/user/{userId}", handlers.GetUserOrganizations) - r.Get("/user/dropdown/{userId}", organizationHandlers.GetUserDropdownOrganizations) - }) - r.Group(func(r chi.Router) { - r.Use(auth.PubKeyContext) - - r.Post("/", organizationHandlers.CreateOrEditOrganization) - r.Post("/users/{uuid}", handlers.CreateOrganizationUser) - r.Delete("/users/{uuid}", handlers.DeleteOrganizationUser) - r.Post("/users/role/{uuid}/{user}", handlers.AddUserRoles) - - r.Get("/foruser/{uuid}", handlers.GetOrganizationUser) - r.Get("/bounty/roles", handlers.GetBountyRoles) - r.Get("/users/role/{uuid}/{user}", handlers.GetUserRoles) - r.Get("/budget/{uuid}", organizationHandlers.GetOrganizationBudget) - r.Get("/budget/history/{uuid}", organizationHandlers.GetOrganizationBudgetHistory) - r.Get("/payments/{uuid}", handlers.GetPaymentHistory) - r.Get("/poll/invoices/{uuid}", organizationHandlers.PollBudgetInvoices) - r.Get("/invoices/count/{uuid}", handlers.GetInvoicesCount) - r.Delete("/delete/{uuid}", organizationHandlers.DeleteOrganization) - }) - return r -} diff --git a/routes/workspaces.go b/routes/workspaces.go new file mode 100644 index 000000000..8a0c8b6ef --- /dev/null +++ b/routes/workspaces.go @@ -0,0 +1,43 @@ +package routes + +import ( + "github.com/go-chi/chi" + "github.com/stakwork/sphinx-tribes/auth" + "github.com/stakwork/sphinx-tribes/db" + "github.com/stakwork/sphinx-tribes/handlers" +) + +func WorkspaceRoutes() chi.Router { + r := chi.NewRouter() + organizationHandlers := handlers.NewWorkspaceHandler(db.DB) + r.Group(func(r chi.Router) { + r.Get("/", handlers.GetWorkspaces) + r.Get("/count", handlers.GetWorkspacesCount) + r.Get("/{uuid}", handlers.GetWorkspaceByUuid) + r.Get("/users/{uuid}", handlers.GetWorkspaceUsers) + r.Get("/users/{uuid}/count", handlers.GetWorkspaceUsersCount) + r.Get("/bounties/{uuid}", organizationHandlers.GetWorkspaceBounties) + r.Get("/bounties/{uuid}/count", organizationHandlers.GetWorkspaceBountiesCount) + r.Get("/user/{userId}", handlers.GetUserWorkspaces) + r.Get("/user/dropdown/{userId}", organizationHandlers.GetUserDropdownWorkspaces) + }) + r.Group(func(r chi.Router) { + r.Use(auth.PubKeyContext) + + r.Post("/", organizationHandlers.CreateOrEditWorkspace) + r.Post("/users/{uuid}", handlers.CreateWorkspaceUser) + r.Delete("/users/{uuid}", handlers.DeleteWorkspaceUser) + r.Post("/users/role/{uuid}/{user}", handlers.AddUserRoles) + + r.Get("/foruser/{uuid}", handlers.GetWorkspaceUser) + r.Get("/bounty/roles", handlers.GetBountyRoles) + r.Get("/users/role/{uuid}/{user}", handlers.GetUserRoles) + r.Get("/budget/{uuid}", organizationHandlers.GetWorkspaceBudget) + r.Get("/budget/history/{uuid}", organizationHandlers.GetWorkspaceBudgetHistory) + r.Get("/payments/{uuid}", handlers.GetPaymentHistory) + r.Get("/poll/invoices/{uuid}", organizationHandlers.PollBudgetInvoices) + r.Get("/invoices/count/{uuid}", handlers.GetInvoicesCount) + r.Delete("/delete/{uuid}", organizationHandlers.DeleteWorkspace) + }) + return r +}