Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing2 #1618

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cfd4613
added count to budget and added workspace/next endpoint
elraphty Apr 17, 2024
c94681f
added completed to bounties status
elraphty Apr 17, 2024
4439c2f
added completed count to filter status count
elraphty Apr 17, 2024
073adc6
Merge pull request #1613 from stakwork/feat/add_count_to_budget
elraphty Apr 17, 2024
ca433a5
changed organization to workdspace
elraphty Apr 18, 2024
9e0e8ff
modified migration
elraphty Apr 22, 2024
326d13e
fixed user roles migration
elraphty Apr 22, 2024
6d0e70c
made UserROles migration conditional
elraphty Apr 22, 2024
f317d8c
added commision for migrating tables with org_uid
elraphty Apr 22, 2024
4ecd700
added conditional for user_roles
elraphty Apr 22, 2024
cf3e62a
added new tables
elraphty Apr 23, 2024
ac293a5
passed all unit tests
elraphty Apr 24, 2024
7667276
Merge pull request #1614 from stakwork/feat/migrate_org_to_workspace
elraphty Apr 24, 2024
9ddf0a3
Include cypress tests
fvalentiner Apr 19, 2024
0baebea
added cypress configurations
elraphty Apr 19, 2024
6b0000b
set up cypress tests
fvalentiner Apr 20, 2024
ba26419
pulled from branch
elraphty Apr 21, 2024
61a08b8
fixed cypress test not passing and added auth
elraphty Apr 21, 2024
4aeae88
Pull Master and Check Cypress tests
AbdulWahab3181 Apr 26, 2024
2dd3bb6
Added workspaces endpoints
AbdulWahab3181 Apr 26, 2024
b51664e
Merge branch 'feature-add-features-endpoints' into testing2
AbdulWahab3181 Apr 26, 2024
e29ba25
Set Mission, Tactics and SchematicUrl as an optional
AbdulWahab3181 Apr 26, 2024
89f0686
Removed Mission, Tactics and SchematicUrl
AbdulWahab3181 Apr 26, 2024
5b05e24
Added Mission, Tactics and SchematicUrl
AbdulWahab3181 Apr 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-on-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ env:

on:
push:
branch:
branches:
- master

jobs:
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/frontend-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Cypress Frontend E2E tests
on:
pull_request:
branches:
- master
- "*"

jobs:
cypress-run:
Expand Down Expand Up @@ -39,10 +39,10 @@ jobs:
chmod 777 -R ./lnd;
chmod 777 -R ./proxy;
chmod 777 -R ./cln;

- name: Check for NODES
uses: nick-fields/retry@v2
with:
with:
timeout_minutes: 10
max_attempts: 3
command: |
Expand All @@ -53,12 +53,12 @@ jobs:
docker logs dave.sphinx
docker wait stack_relaysetup_1
cat stack/relay/NODES.json;

- name: Copy Node.json
uses: canastro/copy-file-action@master
with:
source: 'stack/relay/NODES.json'
target: 'tribes-frontend/cypress/fixtures/nodes.json'
source: "stack/relay/NODES.json"
target: "tribes-frontend/cypress/fixtures/nodes.json"

- name: Install Frontend Dependencies
working-directory: ./tribes-frontend
Expand All @@ -73,14 +73,14 @@ jobs:
run: |
sleep 20
yarn run cypress:run

- name: Upload Cypress logs
if: failure()
uses: actions/upload-artifact@v2
with:
name: cypress-logs
path: tribes-frontend/cypress/videos

- name: Stop Stack
working-directory: ./stack
run: docker-compose down
run: docker-compose down
2 changes: 1 addition & 1 deletion .github/workflows/prjob_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests
on:
pull_request:
branches:
- master
- "*"
jobs:
test-go:
name: Go
Expand Down
3 changes: 3 additions & 0 deletions cypress/e2e/01_workspaces.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('Edit Mission', () => {
headers: { 'x-jwt': `${value}` },
body: {
uuid: Workspaces[0].uuid,
owner_pubkey: Workspaces[0].owner_pubkey,
mission: 'This is a sample mission for workspace'
}
}).then((resp) => {
Expand All @@ -59,6 +60,7 @@ describe('Edit Tactics', () => {
headers: { 'x-jwt': `${value}` },
body: {
uuid: Workspaces[0].uuid,
owner_pubkey: Workspaces[0].owner_pubkey,
mission: 'This is a sample tactics and objectives for workspace'
}
}).then((resp) => {
Expand All @@ -79,6 +81,7 @@ describe('Edit Schematics Url', () => {
headers: { 'x-jwt': `${value}` },
body: {
uuid: Workspaces[0].uuid,
owner_pubkey: Workspaces[0].owner_pubkey,
mission: 'This is a sample schematic url for workspaces'
}
}).then((resp) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
111 changes: 98 additions & 13 deletions db/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

type database struct {
db *gorm.DB
getWorkspaceByUuid func(uuid string) Organization
getUserRoles func(uuid string, pubkey string) []UserRoles
getWorkspaceByUuid func(uuid string) Workspace
getUserRoles func(uuid string, pubkey string) []WorkspaceUserRoles
}

func NewDatabaseConfig(db *gorm.DB) *database {
Expand Down Expand Up @@ -65,17 +65,12 @@ func InitDB() {
db.AutoMigrate(&Channel{})
db.AutoMigrate(&LeaderBoard{})
db.AutoMigrate(&ConnectionCodes{})
db.AutoMigrate(&Bounty{})
db.AutoMigrate(&Organization{})
db.AutoMigrate(&OrganizationUsers{})
db.AutoMigrate(&BountyRoles{})
db.AutoMigrate(&UserRoles{})
db.AutoMigrate(&BountyBudget{})
db.AutoMigrate(&BudgetHistory{})
db.AutoMigrate(&PaymentHistory{})
db.AutoMigrate(&InvoiceList{})
db.AutoMigrate(&UserInvoiceData{})

DB.MigrateTablesWithOrgUuid()
DB.MigrateOrganizationToWorkspace()

people := DB.GetAllPeople()
for _, p := range people {
if p.Uuid == "" {
Expand Down Expand Up @@ -178,6 +173,96 @@ func (db database) GetRolesCount() int64 {
return count
}

func (db database) MigrateTablesWithOrgUuid() {
if !db.db.Migrator().HasTable("bounty") {
if !db.db.Migrator().HasColumn(Bounty{}, "workspace_uuid") {
db.db.AutoMigrate(&Bounty{})
}
}
if !db.db.Migrator().HasTable("budget_histories") {
if !db.db.Migrator().HasColumn(BudgetHistory{}, "workspace_uuid") {
db.db.AutoMigrate(&BudgetHistory{})
}
}
if !db.db.Migrator().HasTable("payment_histories") {
if !db.db.Migrator().HasColumn(PaymentHistory{}, "workspace_uuid") {
db.db.AutoMigrate(&PaymentHistory{})
}
}
if !db.db.Migrator().HasTable("invoice_list") {
if !db.db.Migrator().HasColumn(InvoiceList{}, "workspace_uuid") {
db.db.AutoMigrate(&InvoiceList{})
}
}
if !db.db.Migrator().HasTable("bounty_budgets") {
if !db.db.Migrator().HasColumn(BountyBudget{}, "workspace_uuid") {
db.db.AutoMigrate(&BountyBudget{})
}
}
if !db.db.Migrator().HasTable("workspace_user_roles") {
if !db.db.Migrator().HasColumn(UserRoles{}, "workspace_uuid") {
db.db.AutoMigrate(&UserRoles{})
}
}
if !db.db.Migrator().HasTable("workspaces") {
db.db.AutoMigrate(&Organization{})
}
if !db.db.Migrator().HasTable("workspace_users") {
db.db.AutoMigrate(&OrganizationUsers{})
}
}

func (db database) MigrateOrganizationToWorkspace() {
if (db.db.Migrator().HasTable(&Organization{}) && !db.db.Migrator().HasTable("workspaces")) {
db.db.Migrator().RenameTable(&Organization{}, "workspaces")
}

if (db.db.Migrator().HasTable(&OrganizationUsers{}) && !db.db.Migrator().HasTable("workspace_users")) {
if db.db.Migrator().HasColumn(&OrganizationUsers{}, "org_uuid") {
db.db.Migrator().RenameColumn(&OrganizationUsers{}, "org_uuid", "workspace_uuid")
}
db.db.Migrator().RenameTable(&OrganizationUsers{}, "workspace_users")
}

if (db.db.Migrator().HasTable(&UserRoles{}) && !db.db.Migrator().HasTable("workspace_user_roles")) {
if db.db.Migrator().HasColumn(&UserRoles{}, "org_uuid") {
db.db.Migrator().RenameColumn(&UserRoles{}, "org_uuid", "workspace_uuid")
}

db.db.Migrator().RenameTable(&UserRoles{}, "workspace_user_roles")
}

if (db.db.Migrator().HasTable(&Bounty{})) {
if db.db.Migrator().HasColumn(&Bounty{}, "org_uuid") {
db.db.Migrator().RenameColumn(&Bounty{}, "org_uuid", "workspace_uuid")
}
}

if (db.db.Migrator().HasTable(&BountyBudget{})) {
if db.db.Migrator().HasColumn(&BountyBudget{}, "org_uuid") {
db.db.Migrator().RenameColumn(&BountyBudget{}, "org_uuid", "workspace_uuid")
}
}

if (db.db.Migrator().HasTable(&BudgetHistory{})) {
if db.db.Migrator().HasColumn(&BudgetHistory{}, "org_uuid") {
db.db.Migrator().RenameColumn(&BudgetHistory{}, "org_uuid", "workspace_uuid")
}
}

if (db.db.Migrator().HasTable(&PaymentHistory{})) {
if db.db.Migrator().HasColumn(&PaymentHistory{}, "org_uuid") {
db.db.Migrator().RenameColumn(&PaymentHistory{}, "org_uuid", "workspace_uuid")
}
}

if (db.db.Migrator().HasTable(&InvoiceList{})) {
if db.db.Migrator().HasColumn(&InvoiceList{}, "org_uuid") {
db.db.Migrator().RenameColumn(&InvoiceList{}, "org_uuid", "workspace_uuid")
}
}
}

func (db database) CreateRoles() {
db.db.Create(&ConfigBountyRoles)
}
Expand Down Expand Up @@ -205,7 +290,7 @@ func GetRolesMap() map[string]string {
return roles
}

func GetUserRolesMap(userRoles []UserRoles) map[string]string {
func GetUserRolesMap(userRoles []WorkspaceUserRoles) map[string]string {
roles := map[string]string{}
for _, v := range userRoles {
roles[v.Role] = v.Role
Expand Down Expand Up @@ -235,7 +320,7 @@ func (db database) ConvertMetricsBountiesToMap(metricsCsv []MetricsBountyCsv) []
return metricsMap
}

func RolesCheck(userRoles []UserRoles, check string) bool {
func RolesCheck(userRoles []WorkspaceUserRoles, check string) bool {
rolesMap := GetRolesMap()
userRolesMap := GetUserRolesMap(userRoles)

Expand All @@ -253,7 +338,7 @@ func RolesCheck(userRoles []UserRoles, check string) bool {
return true
}

func CheckUser(userRoles []UserRoles, pubkey string) bool {
func CheckUser(userRoles []WorkspaceUserRoles, pubkey string) bool {
for _, role := range userRoles {
if role.OwnerPubKey == pubkey {
return true
Expand Down
Loading
Loading