Skip to content

Feature/project activity #180

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c6eba74
Winning submission from challenge 30070732
maxceem Sep 17, 2018
004efd6
make git ignore `.env` files which is useful to use for local config …
maxceem Sep 17, 2018
8fb395f
added lastActivityAt and lastActivityUserId to ES project index
maxceem Sep 17, 2018
10f0093
fixed migration script for project activity so lastActivityAt has tim…
maxceem Sep 17, 2018
344098b
Update seed to have the today's date for `lastActivityAt` instead of …
maxceem Sep 17, 2018
9c816dd
Merge branch 'dev' into feature/project-activity
maxceem Sep 17, 2018
931b0e7
Create and use constants for message service events instead of hardco…
maxceem Sep 17, 2018
4874fb3
call ES directly after updating project activity instead of using Rab…
maxceem Sep 17, 2018
2eb9159
fix Kafka consumer to get messages in proper format
maxceem Sep 18, 2018
8f4929a
Use string for lastActivityUserId instead of integers
maxceem Sep 18, 2018
9ff7e4b
move kafka event handlers from service folder to events folder
maxceem Sep 18, 2018
53e66df
adjusted tests for projectUpdatedKafkaHandler
maxceem Sep 19, 2018
3a386fc
fix lint error
maxceem Sep 19, 2018
638dab3
fix tests for kafkaConsumer
maxceem Sep 19, 2018
5fbcb91
fix lint error
maxceem Sep 19, 2018
b7cd0c2
fix projectUpdatedKafkaHandler to use test ES properly
maxceem Sep 19, 2018
652e0dc
fix test broken after lastActivityUserId altered to be a string inste…
maxceem Sep 19, 2018
cc7bd42
make sure that lastActivityUserId is set as a string on project create
maxceem Sep 19, 2018
09e3f4d
adjust test to use set lastActivityUserId as a sting even though thes…
maxceem Sep 19, 2018
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# Created by https://www.gitignore.io/api/node
config/local.js
# can be used locally to config some env variables and after apply them using `source .env`
.env
### Node ###
# Logs
logs
Expand Down
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,33 @@ Run `npm run sync:es` from the root of project to execute the script.

**NOTE**: In production these dependencies / services are hosted & managed outside tc-projects-service.

#### Kafka
Kafka must be installed and configured prior starting the application.
Following topics must be created:
```
notifications.connect.project.updated
notifications.connect.project.files.updated
notifications.connect.project.team.updated
notifications.connect.project.plan.updated
notifications.connect.project.topic.created
notifications.connect.project.topic.updated
notifications.connect.project.post.created
notifications.connect.project.post.edited
```

New Kafka related configuration options has been introduced:
```
"kafkaConfig": {
"hosts": List of Kafka brokers. Default: localhost: 9092
"clientCert": SSL certificate
"clientCertKey": Certificate key
}
```
Environment variables:
KAFKA_HOSTS - same as "hosts"
KAFKA_CLIENT_CERT - same as "clientCert"
KAFKA_CLIENT_CERT_KEY - same as "clientCertKey"

### Test

Each of the individual modules/services are unit tested.
Expand Down
5 changes: 5 additions & 0 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"maxPoolSize": "DB_MAX_POOL_SIZE",
"minPoolSize": "DB_MIN_POOL_SIZE"
},
"kafkaConfig": {
"hosts": "KAFKA_HOSTS",
"clientCert": "KAFKA_CLIENT_CERT",
"clientCertKey": "KAFKA_CLIENT_CERT_KEY"
},
"analyticsKey": "SEGMENT_ANALYTICS_KEY",
"VALID_ISSUERS": "VALID_ISSUERS",
"jwksUri": "JWKS_URI",
Expand Down
2 changes: 2 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"minPoolSize": 4,
"idleTimeout": 1000
},
"kafkaConfig": {
},
"analyticsKey": "",
"VALID_ISSUERS": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
"validIssuers": "[\"https:\/\/topcoder-newauth.auth0.com\/\",\"https:\/\/api.topcoder-dev.com\"]",
Expand Down
18 changes: 18 additions & 0 deletions migrations/20180910_project_activity.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--
-- UPDATE EXISTING TABLES:
-- projects:
-- added column `lastActivityAt`
-- added column `lastActivityUserId`

--
-- projects

-- Add new columns
ALTER TABLE projects ADD COLUMN "lastActivityAt" timestamp with time zone;
ALTER TABLE projects ADD COLUMN "lastActivityUserId" character varying(45);
-- Update new colums
UPDATE projects SET "lastActivityAt"="updatedAt" WHERE "lastActivityAt" is NULL;
UPDATE projects SET "lastActivityUserId"=cast("updatedBy" as varchar) WHERE "lastActivityUserId" is NULL;
-- Set not null
ALTER TABLE projects ALTER COLUMN "lastActivityAt" SET NOT NULL;
ALTER TABLE projects ALTER COLUMN "lastActivityUserId" SET NOT NULL;
7 changes: 7 additions & 0 deletions migrations/elasticsearch_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ function getRequestBody(indexName) {
updatedBy: {
type: 'integer',
},
lastActivityAt: {
type: 'date',
format: 'strict_date_optional_time||epoch_millis',
},
lastActivityUserId: {
type: 'string',
},
utm: {
properties: {
campaign: {
Expand Down
Loading