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

Organizations merge suggestions #1605

Merged
merged 15 commits into from
Oct 3, 2023
Merged
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
9 changes: 5 additions & 4 deletions backend/src/api/organization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export default (app) => {
`/tenant/:tenantId/organization/:organizationId/merge`,
safeWrap(require('./organizationMerge').default),
)
// app.put(
// `/tenant/:tenantId/organization/:organizationId/no-merge`,
// safeWrap(require('./organizationNoMerge').default),
// )

app.put(
`/tenant/:tenantId/organization/:organizationId/no-merge`,
safeWrap(require('./organizationNotMerge').default),
)
}
16 changes: 16 additions & 0 deletions backend/src/api/organization/organizationNotMerge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import OrganizationService from '@/services/organizationService'
import Permissions from '../../security/permissions'
import track from '../../segment/track'
import PermissionChecker from '../../services/user/permissionChecker'

export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.organizationEdit)
await new OrganizationService(req).addToNoMerge(
req.params.organizationId,
req.body.organizationToNotMerge,
)

track('Ignore merge organizations', {}, { ...req })

await req.responseHandler.success(req, res, { status: 200 })
}
4 changes: 4 additions & 0 deletions backend/src/api/tenant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default (app) => {
app.get(`/tenant/url`, safeWrap(require('./tenantFind').default))
app.get(`/tenant/:id`, safeWrap(require('./tenantFind').default))
app.get(`/tenant/:tenantId/membersToMerge`, safeWrap(require('./tenantMembersToMerge').default))
app.get(
`/tenant/:tenantId/organizationsToMerge`,
safeWrap(require('./tenantOrganizationsToMerge').default),
)
app.post(`/tenant/:tenantId/sampleData`, safeWrap(require('./tenantGenerateSampleData').default))
app.delete(`/tenant/:tenantId/sampleData`, safeWrap(require('./tenantDeleteSampleData').default))
}
12 changes: 12 additions & 0 deletions backend/src/api/tenant/tenantOrganizationsToMerge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Error403 from '../../errors/Error403'
import TenantService from '../../services/tenantService'

export default async (req, res) => {
if (!req.currentUser || !req.currentUser.id) {
throw new Error403(req.language)
}

const payload = await new TenantService(req).findOrganizationsToMerge(req.query)

await req.responseHandler.success(req, res, payload)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
create table
public."organizationToMerge" (
"createdAt" timestamp
with
time zone not null,
"updatedAt" timestamp
with
time zone not null,
"organizationId" uuid not null references public.organizations on update cascade on delete cascade,
"toMergeId" uuid not null references public.organizations on update cascade on delete cascade,
similarity double precision,
primary key ("organizationId", "toMergeId")
);

create index "ix_organizationToMerge_toMergeId" on public."organizationToMerge" ("toMergeId");

create table
public."organizationNoMerge" (
"createdAt" timestamp
with
time zone not null,
"updatedAt" timestamp
with
time zone not null,
"organizationId" uuid not null references public.organizations on update cascade on delete cascade,
"noMergeId" uuid not null references public.organizations on update cascade on delete cascade,
primary key ("organizationId", "noMergeId")
);

create index "ix_organizationNoMerge_noMergeId" on public."organizationNoMerge" ("noMergeId");
Loading
Loading