Skip to content

Commit

Permalink
Merge pull request #1631 from MirzaHanan/Add-Endpoints-for-Workspace-…
Browse files Browse the repository at this point in the history
…Repo

Fixed: Add Endpoints for Workspace Repositories
  • Loading branch information
elraphty authored May 6, 2024
2 parents 3c8fdc1 + ba5ebd8 commit 356f165
Show file tree
Hide file tree
Showing 14 changed files with 705 additions and 260 deletions.
40 changes: 40 additions & 0 deletions cypress/e2e/02_repositories.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { User, HostName, Workspaces, Repositories } from '../support/objects/objects';


describe('Create Repositories for Workspace', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
for(let i = 0; i <= 1; i++) {
cy.request({
method: 'POST',
url: `${HostName}/workspaces/repositories`,
headers: { 'x-jwt': `${value}` },
body: Repositories[i]
}).its('body').then(body => {
expect(body).to.have.property('name').and.equal(Repositories[i].name.trim());
expect(body).to.have.property('url').and.equal(Repositories[i].url.trim());
});
}
})
})
})


describe('Check Repositories Values', () => {
it('passes', () => {
cy.upsertlogin(User).then(value => {
cy.request({
method: 'GET',
url: `${HostName}/workspaces/repositories/` + Repositories[0].workspace_uuid,
headers: { 'x-jwt': `${ value }` },
body: {}
}).then((resp) => {
expect(resp.status).to.eq(200)
expect(resp.body[0]).to.have.property('name', Repositories[0].name.trim())
expect(resp.body[0]).to.have.property('url', Repositories[0].url.trim())
expect(resp.body[1]).to.have.property('name', Repositories[1].name.trim())
expect(resp.body[1]).to.have.property('url', Repositories[1].url.trim())
})
})
})
})
2 changes: 1 addition & 1 deletion cypress/support/objects/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Repositories = [
url: ' https://github.com/stakwork/sphinx-tribes-frontend '
},
{
uuid: 'com1t3gn1e4a4qu3tnlg',
uuid: 'com1t3gn1e4a4qu3thss',
workspace_uuid: 'cohob00n1e4808utqel0',
name: ' backend ',
url: ' https://github.com/stakwork/sphinx-tribes '
Expand Down
9 changes: 9 additions & 0 deletions db/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func InitDB() {
db.AutoMigrate(&ConnectionCodes{})
db.AutoMigrate(&BountyRoles{})
db.AutoMigrate(&UserInvoiceData{})
db.AutoMigrate(&WorkspaceRepositories{})
db.AutoMigrate(&WorkspaceFeatures{})

DB.MigrateTablesWithOrgUuid()
Expand Down Expand Up @@ -178,6 +179,8 @@ func (db database) MigrateTablesWithOrgUuid() {
if !db.db.Migrator().HasTable("bounty") {
if !db.db.Migrator().HasColumn(Bounty{}, "workspace_uuid") {
db.db.AutoMigrate(&Bounty{})
} else {
db.db.AutoMigrate(&NewBounty{})
}
}
if !db.db.Migrator().HasTable("budget_histories") {
Expand All @@ -188,16 +191,22 @@ func (db database) MigrateTablesWithOrgUuid() {
if !db.db.Migrator().HasTable("payment_histories") {
if !db.db.Migrator().HasColumn(PaymentHistory{}, "workspace_uuid") {
db.db.AutoMigrate(&PaymentHistory{})
} else {
db.db.AutoMigrate(&NewPaymentHistory{})
}
}
if !db.db.Migrator().HasTable("invoice_list") {
if !db.db.Migrator().HasColumn(InvoiceList{}, "workspace_uuid") {
db.db.AutoMigrate(&InvoiceList{})
} else {
db.db.AutoMigrate(&NewInvoiceList{})
}
}
if !db.db.Migrator().HasTable("bounty_budgets") {
if !db.db.Migrator().HasColumn(BountyBudget{}, "workspace_uuid") {
db.db.AutoMigrate(&BountyBudget{})
} else {
db.db.AutoMigrate(&NewBountyBudget{})
}
}
if !db.db.Migrator().HasTable("workspace_user_roles") {
Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ func (db database) GetAllBounties(r *http.Request) []NewBounty {
languageArray := strings.Split(languages, ",")
languageLength := len(languageArray)

if workspaceUuid != "" && orgUuid != "" {
if workspaceUuid == "" && orgUuid != "" {
workspaceUuid = orgUuid
}

Expand Down
25 changes: 14 additions & 11 deletions db/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,26 @@ type Database interface {
DeleteAllUsersFromWorkspace(uuid string) error
GetFilterStatusCount() FilterStattuCount
UserHasManageBountyRoles(pubKeyFromAuth string, uuid string) bool
BountiesPaidPercentage(r PaymentDateRange) uint
TotalSatsPosted(r PaymentDateRange) uint
TotalSatsPaid(r PaymentDateRange) uint
SatsPaidPercentage(r PaymentDateRange) uint
AveragePaidTime(r PaymentDateRange) uint
AverageCompletedTime(r PaymentDateRange) uint
TotalBountiesPosted(r PaymentDateRange) int64
TotalPaidBounties(r PaymentDateRange) int64
NewHuntersPaid(r PaymentDateRange) int64
TotalHuntersPaid(r PaymentDateRange) int64
BountiesPaidPercentage(r PaymentDateRange, workspace string) uint
TotalSatsPosted(r PaymentDateRange, workspace string) uint
TotalSatsPaid(r PaymentDateRange, workspace string) uint
SatsPaidPercentage(r PaymentDateRange, workspace string) uint
AveragePaidTime(r PaymentDateRange, workspace string) uint
AverageCompletedTime(r PaymentDateRange, workspace string) uint
TotalBountiesPosted(r PaymentDateRange, workspace string) int64
TotalPaidBounties(r PaymentDateRange, workspace string) int64
TotalAssignedBounties(r PaymentDateRange, workspace string) int64
NewHuntersPaid(r PaymentDateRange, workspace string) int64
TotalHuntersPaid(r PaymentDateRange, workspace string) int64
GetPersonByPubkey(pubkey string) Person
GetBountiesByDateRange(r PaymentDateRange, re *http.Request) []Bounty
GetBountiesByDateRange(r PaymentDateRange, re *http.Request) []NewBounty
GetBountiesByDateRangeCount(r PaymentDateRange, re *http.Request) int64
GetBountiesProviders(r PaymentDateRange, re *http.Request) []Person
PersonUniqueNameFromName(name string) (string, error)
ProcessAlerts(p Person)
UserHasAccess(pubKeyFromAuth string, uuid string, role string) bool
CreateWorkspaceRepository(m WorkspaceRepositories) (WorkspaceRepositories, error)
GetWorkspaceRepositorByWorkspaceUuid(uuid string) []WorkspaceRepositories
CreateOrEditFeature(m WorkspaceFeatures) (WorkspaceFeatures, error)
GetFeaturesByWorkspaceUuid(uuid string) []WorkspaceFeatures
GetFeatureByUuid(uuid string) WorkspaceFeatures
Expand Down
Loading

0 comments on commit 356f165

Please sign in to comment.