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

organization -> organisation #2148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
338 changes: 176 additions & 162 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ of it.
**you** refers to the individual or entity agreeing to these terms.

**your company** is any legal entity, sole proprietorship, or other kind of
organization that you work for, plus all organizations that have control over,
organisation that you work for, plus all organisations that have control over,
are under the control of, or are under common control with that
organization. 'control' means ownership of substantially all the assets of an
organisation. 'control' means ownership of substantially all the assets of an
entity, or the power to direct its management and policies by vote, contract, or
otherwise. Control can be direct or indirect.

Expand Down
4 changes: 2 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ func (a *ApplicationHandler) BuildControlPlaneRoutes() *chi.Mux {

orgSubRouter.Route("/invites", func(orgInvitesRouter chi.Router) {
orgInvitesRouter.Post("/", handler.InviteUserToOrganisation)
orgInvitesRouter.Post("/{inviteID}/resend", handler.ResendOrganizationInvite)
orgInvitesRouter.Post("/{inviteID}/cancel", handler.CancelOrganizationInvite)
orgInvitesRouter.Post("/{inviteID}/resend", handler.ResendOrganisationInvite)
orgInvitesRouter.Post("/{inviteID}/cancel", handler.CancelOrganisationInvite)
orgInvitesRouter.With(middleware.Pagination).Get("/pending", handler.GetPendingOrganisationInvites)
})

Expand Down
4 changes: 2 additions & 2 deletions api/handlers/organisation_invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (h *Handler) FindUserByInviteToken(w http.ResponseWriter, r *http.Request)
_ = render.Render(w, r, util.NewServerResponse("retrieved user", res, http.StatusOK))
}

func (h *Handler) ResendOrganizationInvite(w http.ResponseWriter, r *http.Request) {
func (h *Handler) ResendOrganisationInvite(w http.ResponseWriter, r *http.Request) {
user, err := h.retrieveUser(r)
if err != nil {
_ = render.Render(w, r, util.NewServiceErrResponse(err))
Expand Down Expand Up @@ -180,7 +180,7 @@ func (h *Handler) ResendOrganizationInvite(w http.ResponseWriter, r *http.Reques
_ = render.Render(w, r, util.NewServerResponse("invite resent successfully", nil, http.StatusOK))
}

func (h *Handler) CancelOrganizationInvite(w http.ResponseWriter, r *http.Request) {
func (h *Handler) CancelOrganisationInvite(w http.ResponseWriter, r *http.Request) {
org, err := h.retrieveOrganisation(r)
if err != nil {
_ = render.Render(w, r, util.NewServiceErrResponse(err))
Expand Down
2 changes: 1 addition & 1 deletion configs/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ services:
image: bitnami/postgresql:latest
restart: on-failure
ports:
- "5432:5432"
- "5433:5432"
environment:
POSTGRESQL_DATABASE: convoy
POSTGRESQL_USERNAME: convoy
Expand Down
60 changes: 30 additions & 30 deletions database/postgres/organisation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import (
)

var (
ErrOrganizationNotCreated = errors.New("organization could not be created")
ErrOrganizationNotUpdated = errors.New("organization could not be updated")
ErrOrganizationNotDeleted = errors.New("organization could not be deleted")
ErrOrganisationNotCreated = errors.New("organisation could not be created")
ErrOrganisationNotUpdated = errors.New("organisation could not be updated")
ErrOrganisationNotDeleted = errors.New("organisation could not be deleted")
)

const (
createOrganization = `
createOrganisation = `
INSERT INTO convoy.organisations (id, name, owner_id, custom_domain, assigned_domain)
VALUES ($1, $2, $3, $4, $5);
`
Expand All @@ -37,7 +37,7 @@ const (
SELECT * FROM convoy.organisations WHERE deleted_at IS NULL
`

updateOrganizationById = `
updateOrganisationById = `
UPDATE convoy.organisations SET
name = $2,
custom_domain = $3,
Expand All @@ -52,27 +52,27 @@ const (
WHERE id = $1 AND deleted_at IS NULL;
`

baseFetchOrganizationsPagedForward = `
baseFetchOrganisationsPagedForward = `
%s
AND id <= :cursor
GROUP BY id
ORDER BY id DESC
LIMIT :limit
`

baseFetchOrganizationsPagedBackward = `
WITH organizations AS (
baseFetchOrganisationsPagedBackward = `
WITH organisations AS (
%s
AND id >= :cursor
GROUP BY id
ORDER BY id ASC
LIMIT :limit
)

SELECT * FROM organizations ORDER BY id DESC
SELECT * FROM organisations ORDER BY id DESC
`

countPrevOrganizations = `
countPrevOrganisations = `
SELECT COUNT(DISTINCT(id)) AS count
FROM convoy.organisations
WHERE deleted_at IS NULL
Expand All @@ -81,7 +81,7 @@ const (
ORDER BY id DESC
LIMIT 1`

countOrganizations = `
countOrganisations = `
SELECT COUNT(*) AS count
FROM convoy.organisations
WHERE deleted_at IS NULL`
Expand All @@ -100,7 +100,7 @@ func NewOrgRepo(db database.Database, ca cache.Cache) datastore.OrganisationRepo
}

func (o *orgRepo) CreateOrganisation(ctx context.Context, org *datastore.Organisation) error {
result, err := o.db.ExecContext(ctx, createOrganization, org.UID, org.Name, org.OwnerID, org.CustomDomain, org.AssignedDomain)
result, err := o.db.ExecContext(ctx, createOrganisation, org.UID, org.Name, org.OwnerID, org.CustomDomain, org.AssignedDomain)
if err != nil {
return err
}
Expand All @@ -111,7 +111,7 @@ func (o *orgRepo) CreateOrganisation(ctx context.Context, org *datastore.Organis
}

if rowsAffected < 1 {
return ErrOrganizationNotCreated
return ErrOrganisationNotCreated
}

orCacheKey := convoy.OrganisationCacheKey.Get(org.UID).String()
Expand All @@ -126,9 +126,9 @@ func (o *orgRepo) CreateOrganisation(ctx context.Context, org *datastore.Organis
func (o *orgRepo) LoadOrganisationsPaged(ctx context.Context, pageable datastore.Pageable) ([]datastore.Organisation, datastore.PaginationData, error) {
var query string
if pageable.Direction == datastore.Next {
query = baseFetchOrganizationsPagedForward
query = baseFetchOrganisationsPagedForward
} else {
query = baseFetchOrganizationsPagedBackward
query = baseFetchOrganisationsPagedBackward
}

query = fmt.Sprintf(query, fetchOrganisationsPaged)
Expand Down Expand Up @@ -156,7 +156,7 @@ func (o *orgRepo) LoadOrganisationsPaged(ctx context.Context, pageable datastore
}
defer closeWithError(rows)

organizations := make([]datastore.Organisation, 0)
organisations := make([]datastore.Organisation, 0)
for rows.Next() {
var org datastore.Organisation

Expand All @@ -165,17 +165,17 @@ func (o *orgRepo) LoadOrganisationsPaged(ctx context.Context, pageable datastore
return nil, datastore.PaginationData{}, err
}

organizations = append(organizations, org)
organisations = append(organisations, org)
}

var count datastore.PrevRowCount
if len(organizations) > 0 {
if len(organisations) > 0 {
var countQuery string
var qargs []interface{}

arg["cursor"] = organizations[0].UID
arg["cursor"] = organisations[0].UID

countQuery, qargs, err = sqlx.Named(countPrevOrganizations, arg)
countQuery, qargs, err = sqlx.Named(countPrevOrganisations, arg)
if err != nil {
return nil, datastore.PaginationData{}, err
}
Expand All @@ -197,23 +197,23 @@ func (o *orgRepo) LoadOrganisationsPaged(ctx context.Context, pageable datastore
}
}

ids := make([]string, len(organizations))
for i := range organizations {
ids[i] = organizations[i].UID
ids := make([]string, len(organisations))
for i := range organisations {
ids[i] = organisations[i].UID
}

if len(organizations) > pageable.PerPage {
organizations = organizations[:len(organizations)-1]
if len(organisations) > pageable.PerPage {
organisations = organisations[:len(organisations)-1]
}

pagination := &datastore.PaginationData{PrevRowCount: count}
pagination = pagination.Build(pageable, ids)

return organizations, *pagination, nil
return organisations, *pagination, nil
}

func (o *orgRepo) UpdateOrganisation(ctx context.Context, org *datastore.Organisation) error {
result, err := o.db.ExecContext(ctx, updateOrganizationById, org.UID, org.Name, org.CustomDomain, org.AssignedDomain)
result, err := o.db.ExecContext(ctx, updateOrganisationById, org.UID, org.Name, org.CustomDomain, org.AssignedDomain)
if err != nil {
return err
}
Expand All @@ -224,7 +224,7 @@ func (o *orgRepo) UpdateOrganisation(ctx context.Context, org *datastore.Organis
}

if rowsAffected < 1 {
return ErrOrganizationNotUpdated
return ErrOrganisationNotUpdated
}

orCacheKey := convoy.OrganisationCacheKey.Get(org.UID).String()
Expand All @@ -248,7 +248,7 @@ func (o *orgRepo) DeleteOrganisation(ctx context.Context, uid string) error {
}

if rowsAffected < 1 {
return ErrOrganizationNotDeleted
return ErrOrganisationNotDeleted
}

orgCacheKey := convoy.OrganisationCacheKey.Get(uid).String()
Expand All @@ -262,7 +262,7 @@ func (o *orgRepo) DeleteOrganisation(ctx context.Context, uid string) error {

func (o *orgRepo) CountOrganisations(ctx context.Context) (int64, error) {
var count int64
err := o.db.GetContext(ctx, &count, countOrganizations)
err := o.db.GetContext(ctx, &count, countOrganisations)
if err != nil {
return 0, err
}
Expand Down
12 changes: 6 additions & 6 deletions database/postgres/organisation_invite.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
)

var (
ErrOrganizationInviteNotCreated = errors.New("organization invite could not be created")
ErrOrganizationInviteNotUpdated = errors.New("organization invite could not be updated")
ErrOrganizationInviteNotDeleted = errors.New("organization invite could not be deleted")
ErrOrganisationInviteNotCreated = errors.New("organisation invite could not be created")
ErrOrganisationInviteNotUpdated = errors.New("organisation invite could not be updated")
ErrOrganisationInviteNotDeleted = errors.New("organisation invite could not be deleted")
)

const (
Expand Down Expand Up @@ -165,7 +165,7 @@ func (i *orgInviteRepo) CreateOrganisationInvite(ctx context.Context, iv *datast
}

if rowsAffected < 1 {
return ErrOrganizationInviteNotCreated
return ErrOrganisationInviteNotCreated
}

return nil
Expand Down Expand Up @@ -294,7 +294,7 @@ func (i *orgInviteRepo) UpdateOrganisationInvite(ctx context.Context, iv *datast
}

if rowsAffected < 1 {
return ErrOrganizationInviteNotUpdated
return ErrOrganisationInviteNotUpdated
}

return nil
Expand All @@ -312,7 +312,7 @@ func (i *orgInviteRepo) DeleteOrganisationInvite(ctx context.Context, id string)
}

if rowsAffected < 1 {
return ErrOrganizationInviteNotDeleted
return ErrOrganisationInviteNotDeleted
}

return nil
Expand Down
12 changes: 6 additions & 6 deletions database/postgres/organisation_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
)

var (
ErrOrganizationMemberNotCreated = errors.New("organization member could not be created")
ErrOrganizationMemberNotUpdated = errors.New("organization member could not be updated")
ErrOrganizationMemberNotDeleted = errors.New("organization member could not be deleted")
ErrOrganisationMemberNotCreated = errors.New("organisation member could not be created")
ErrOrganisationMemberNotUpdated = errors.New("organisation member could not be updated")
ErrOrganisationMemberNotDeleted = errors.New("organisation member could not be deleted")
)

const (
Expand Down Expand Up @@ -216,7 +216,7 @@ func (o *orgMemberRepo) CreateOrganisationMember(ctx context.Context, member *da
}

if nRows < 1 {
return ErrOrganizationMemberNotCreated
return ErrOrganisationMemberNotCreated
}

return nil
Expand Down Expand Up @@ -451,7 +451,7 @@ func (o *orgMemberRepo) UpdateOrganisationMember(ctx context.Context, member *da
}

if nRows < 1 {
return ErrOrganizationMemberNotUpdated
return ErrOrganisationMemberNotUpdated
}

return nil
Expand All @@ -469,7 +469,7 @@ func (o *orgMemberRepo) DeleteOrganisationMember(ctx context.Context, uid, orgID
}

if nRows < 1 {
return ErrOrganizationMemberNotDeleted
return ErrOrganisationMemberNotDeleted
}

return nil
Expand Down
Loading
Loading