Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit affbf6e

Browse files
Merge winning submission from enrich contest
1 parent d7da58b commit affbf6e

File tree

15 files changed

+220
-81
lines changed

15 files changed

+220
-81
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ The following parameters can be set in config files or in env variables:
2929
- GROUPS_MEMBERSHIP_TYPE: the groups membership type that should be processed, default value is 'user'
3030
- ES.HOST: Elasticsearch host, default value is 'localhost:9200'
3131
- ES.AWS_REGION: The Amazon region to use when using AWS Elasticsearch service, default value is 'us-east-1'
32-
- ES.API_VERSION: Elasticsearch API version, default value is '7.4'
3332
- ES.ACHIEVEMENT_PROVIDER_INDEX: Elasticsearch index name for achievement provider, default value is 'achievement_provider'
3433
- ES.ACHIEVEMENT_PROVIDER_TYPE: Elasticsearch index type for achievement provider, default value is '_doc'
3534
- ES.ATTRIBUTE_INDEX: Elasticsearch index name for attribute, default value is 'attribute'
@@ -53,6 +52,7 @@ The following parameters can be set in config files or in env variables:
5352
- ES.USER_SKILL_PROPERTY_NAME: the user property name of skill, default value is 'skills'
5453
- ES.ORGANIZATION_SKILLPROVIDER_PROPERTY_NAME: the org property name of org skill providers, default value is 'skillProviders'
5554
- ES.USER_GROUP_PROPERTY_NAME: the user property name of group, default value is 'groups'
55+
- ENRICH_USER_PIPELINE_NAME: the user enrich pipeline name, default value is 'enrich_user'
5656

5757
There is a `/health` endpoint that checks for the health of the app. This sets up an expressjs server and listens on the environment variable `PORT`. It's not part of the configuration file and needs to be passed as an environment variable
5858

config/default.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ module.exports = {
2323
GROUPS_MEMBERSHIP_TYPE: process.env.GROUPS_MEMBERSHIP_TYPE || 'user',
2424

2525
ES: {
26-
HOST: process.env.ES_HOST || 'localhost:9200',
26+
HOST: process.env.ES_HOST || 'http://localhost:9200',
2727
AWS_REGION: process.env.AWS_REGION || 'us-east-1', // AWS Region to be used if we use AWS ES
28-
API_VERSION: process.env.ES_API_VERSION || '7.4',
2928
ACHIEVEMENT_PROVIDER_INDEX: process.env.ACHIEVEMENT_PROVIDER_INDEX || 'achievement_provider',
3029
ACHIEVEMENT_PROVIDER_TYPE: process.env.ACHIEVEMENT_PROVIDER_TYPE || '_doc',
3130
ATTRIBUTE_INDEX: process.env.ATTRIBUTE_INDEX || 'attribute',
@@ -50,6 +49,8 @@ module.exports = {
5049
USER_SKILL_PROPERTY_NAME: process.env.USER_SKILL_PROPERTY_NAME || 'skills',
5150
USER_GROUP_PROPERTY_NAME: process.env.USER_GROUP_PROPERTY_NAME || 'groups',
5251

53-
ORGANIZATION_SKILLPROVIDER_PROPERTY_NAME: process.env.ORGANIZATION_SKILLPROVIDER_PROPERTY_NAME || 'skillProviders'
52+
ORGANIZATION_SKILLPROVIDER_PROPERTY_NAME: process.env.ORGANIZATION_SKILLPROVIDER_PROPERTY_NAME || 'skillProviders',
53+
54+
ENRICH_USER_PIPELINE_NAME: process.env.ENRICH_USER_PIPELINE_NAME || 'enrich_user'
5455
}
5556
}

docker-kafka-es/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
KAFKA_CREATE_TOPICS: "u-bahn.action.aggregate:1:1,groups.notification.member.add:1:1,groups.notification.member.delete:1:1"
1616
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
1717
esearch:
18-
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2
18+
image: elasticsearch:7.7.1
1919
container_name: ubahn-data-processor-es_es
2020
ports:
2121
- "9200:9200"

package-lock.json

Lines changed: 65 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
"superagent": "^5.1.0"
2727
},
2828
"dependencies": {
29+
"@elastic/elasticsearch": "^7.9.1",
2930
"@hapi/joi": "^15.1.0",
3031
"async-mutex": "^0.2.4",
32+
"aws-elasticsearch-connector": "^9.0.0",
3133
"aws-sdk": "^2.476.0",
3234
"bluebird": "^3.5.5",
3335
"config": "^3.1.0",
34-
"elasticsearch": "^16.7.1",
3536
"get-parameter-names": "^0.3.0",
36-
"http-aws-es": "^6.0.0",
3737
"lodash": "^4.17.19",
3838
"no-kafka": "^3.4.3",
3939
"topcoder-healthcheck-dropin": "^1.0.3",

src/common/constants.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ const { validProperties } = require('./helper')
88
const topResources = {
99
achievementprovider: {
1010
index: config.get('ES.ACHIEVEMENT_PROVIDER_INDEX'),
11+
mappingFields: ['id', 'achievementsProviderId', 'name', 'uri', 'certifierId', 'certifiedDate', 'created', 'updated', 'createdBy', 'updatedBy'],
12+
enrichPolicy: 'achievementprovider-policy',
1113
type: config.get('ES.ACHIEVEMENT_PROVIDER_TYPE')
1214
},
1315
attribute: {
1416
index: config.get('ES.ATTRIBUTE_INDEX'),
17+
enrichPolicy: 'attribute-policy',
18+
mappingFields: ['id', 'name', 'attributeGroupId', 'created', 'updated', 'createdBy', 'updatedBy'],
1519
type: config.get('ES.ATTRIBUTE_TYPE')
1620
},
1721
attributegroup: {
@@ -21,14 +25,20 @@ const topResources = {
2125

2226
organization: {
2327
index: config.get('ES.ORGANIZATION_INDEX'),
28+
enrichPolicy: 'organization-policy',
29+
mappingFields: ['id', 'name', 'created', 'updated', 'createdBy', 'updatedBy'],
2430
type: config.get('ES.ORGANIZATION_TYPE')
2531
},
2632
role: {
2733
index: config.get('ES.ROLE_INDEX'),
34+
enrichPolicy: 'role-policy',
35+
mappingFields: ['id', 'name', 'created', 'updated', 'createdBy', 'updatedBy'],
2836
type: config.get('ES.ROLE_TYPE')
2937
},
3038
skill: {
3139
index: config.get('ES.SKILL_INDEX'),
40+
enrichPolicy: 'skill-policy',
41+
mappingFields: ['id', 'skillProviderId', 'name', 'externalId', 'uri', 'created', 'updated', 'createdBy', 'updatedBy'],
3242
type: config.get('ES.SKILL_TYPE')
3343
},
3444
skillprovider: {
@@ -44,27 +54,32 @@ const topResources = {
4454
const userResources = {
4555
achievement: {
4656
propertyName: config.get('ES.USER_ACHIEVEMENT_PROPERTY_NAME'),
57+
relateTopResource: 'achievementprovider',
4758
relateKey: 'achievementsProviderId',
4859
validate: payload => validProperties(payload, ['userId', 'achievementsProviderId'])
4960
},
5061
externalprofile: {
5162
propertyName: config.get('ES.USER_EXTERNALPROFILE_PROPERTY_NAME'),
63+
relateTopResource: 'organization',
5264
relateKey: 'organizationId',
5365
validate: payload => validProperties(payload, ['userId', 'organizationId'])
5466
},
5567
userattribute: {
5668
propertyName: config.get('ES.USER_ATTRIBUTE_PROPERTY_NAME'),
69+
relateTopResource: 'attribute',
5770
relateKey: 'attributeId',
5871
validate: payload => validProperties(payload, ['userId', 'attributeId']),
5972
isNested: true // For ES index creation
6073
},
6174
userrole: {
6275
propertyName: config.get('ES.USER_ROLE_PROPERTY_NAME'),
76+
relateTopResource: 'role',
6377
relateKey: 'roleId',
6478
validate: payload => validProperties(payload, ['userId', 'roleId'])
6579
},
6680
userskill: {
6781
propertyName: config.get('ES.USER_SKILL_PROPERTY_NAME'),
82+
relateTopResource: 'skill',
6883
relateKey: 'skillId',
6984
validate: payload => validProperties(payload, ['userId', 'skillId'])
7085
}

0 commit comments

Comments
 (0)