Skip to content

Commit 3ca013a

Browse files
committed
Show manually created organizations and members
1 parent d5344c2 commit 3ca013a

23 files changed

+70
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE public."organizations" DROP COLUMN "manuallyCreated";
2+
ALTER TABLE public."members" DROP COLUMN "manuallyCreated";
3+
ALTER TABLE public."organizationCaches" DROP COLUMN "manuallyCreated";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE public."members" ADD COLUMN "manuallyCreated" boolean NOT NULL DEFAULT false;
2+
ALTER TABLE public."organizations" ADD COLUMN "manuallyCreated" boolean NOT NULL DEFAULT false;
3+
ALTER TABLE public."organizationCaches" ADD COLUMN "manuallyCreated" boolean NOT NULL DEFAULT false;

backend/src/database/models/member.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ export default (sequelize) => {
5757
enrichedBy: {
5858
type: DataTypes.ARRAY(DataTypes.TEXT),
5959
},
60+
manuallyCreated: {
61+
type: DataTypes.BOOLEAN,
62+
allowNull: false,
63+
defaultValue: false,
64+
},
6065
},
6166
{
6267
indexes: [

backend/src/database/models/organization.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ export default (sequelize) => {
150150
type: DataTypes.DATE,
151151
allowNull: true,
152152
},
153+
manuallyCreated: {
154+
type: DataTypes.BOOLEAN,
155+
allowNull: false,
156+
defaultValue: false,
157+
},
153158
attributes: {
154159
type: DataTypes.JSONB,
155160
defaultValue: {},

backend/src/database/models/organizationCache.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ export default (sequelize) => {
133133
type: DataTypes.DATE,
134134
allowNull: true,
135135
},
136+
manuallyCreated: {
137+
type: DataTypes.BOOLEAN,
138+
allowNull: false,
139+
defaultValue: false,
140+
},
136141
},
137142
{
138143
indexes: [

backend/src/database/repositories/__tests__/organizationCacheRepository.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const toCreate = {
5050
founded: null,
5151
employeeCountByCountry: null,
5252
address: null,
53+
manuallyCreated: false,
5354
}
5455

5556
describe('OrganizationCacheCacheRepository tests', () => {

backend/src/database/repositories/__tests__/organizationRepository.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const toCreate = {
5252
employeeCountByCountry: null,
5353
address: null,
5454
profiles: null,
55+
manuallyCreated: false,
5556
}
5657

5758
async function createMembers(options) {
@@ -579,6 +580,7 @@ describe('OrganizationRepository tests', () => {
579580
min: 10,
580581
max: 50,
581582
},
583+
manuallyCreated: false,
582584
}
583585

584586
const piedpiper = {
@@ -611,6 +613,7 @@ describe('OrganizationRepository tests', () => {
611613
min: 0,
612614
max: 1,
613615
},
616+
manuallyCreated: false,
614617
}
615618

616619
const hooli = {
@@ -643,6 +646,7 @@ describe('OrganizationRepository tests', () => {
643646
min: 200,
644647
max: 500,
645648
},
649+
manuallyCreated: false,
646650
}
647651

648652
it('Should filter by name', async () => {

backend/src/database/repositories/memberRepository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class MemberRepository {
8585
'score',
8686
'reach',
8787
'joinedAt',
88+
'manuallyCreated',
8889
'importHash',
8990
]),
9091
tenantId: tenant.id,

backend/src/database/repositories/organizationCacheRepository.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class OrganizationCacheRepository {
4040
'address',
4141
'size',
4242
'lastEnrichedAt',
43+
'manuallyCreated',
4344
]),
4445
},
4546
{

backend/src/database/repositories/organizationRepository.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class OrganizationRepository {
120120
'founded',
121121
'size',
122122
'lastEnrichedAt',
123+
'manuallyCreated',
123124
]),
124125

125126
tenantId: tenant.id,
@@ -630,9 +631,18 @@ class OrganizationRepository {
630631

631632
if (filter.and) {
632633
filter.and.push({
633-
activityCount: {
634-
gt: 0,
635-
},
634+
or: [
635+
{
636+
manuallyCreated: {
637+
eq: true,
638+
},
639+
},
640+
{
641+
activityCount: {
642+
gt: 0,
643+
},
644+
},
645+
],
636646
})
637647
}
638648

@@ -685,6 +695,8 @@ class OrganizationRepository {
685695
}
686696
}
687697

698+
console.log('parsed organization query', JSON.stringify(parsed))
699+
688700
const response = await options.opensearch.search({
689701
index: OpenSearchIndex.ORGANIZATIONS,
690702
body: parsed,

0 commit comments

Comments
 (0)