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

Commit f299c1f

Browse files
miscellaneous
1 parent afd44af commit f299c1f

18 files changed

+58
-3864
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ Setup your Elasticsearch instance and ensure that it is up and running.
6262

6363
1. Follow *Configuration* section to update config values, like database, etc ..
6464
2. Goto *UBahn-api*, run `npm i` and `npm run lint`
65-
3. Import mock data, `node scripts/db/genData.js`, this will gen some data for test (if you need this)
65+
3. Run the migrations - `npm run migrations up`. This will create the database, the tables and insert mock data into the database. You will then run `npm run migrate-db-to-es` to migrate the data to elasticsearch from the database
6666
4. Startup server `node app.js` or `npm run start`
6767

68-
## Working with mock data
68+
## Migrations
6969

70-
You can use the scripts `npm run migrations up` (and `npm run migrations down`) to insert mock data (and delete mock data respectively). The data is inserted into Postgres and Elasticsearch. You need to setup the configurations beforehand and also start the elasticsearch instance before you run these scripts. You can run the script `npm run migrate-db-to-es` to dump data in db into es.
70+
Migrations are located under the `./scripts/db/` folder. Run `npm run migrations up` and `npm run migrations down` to execute the migrations or remove the earlier ones
7171

7272
## Local Deployment with Docker
7373

@@ -87,6 +87,4 @@ Make sure all config values are right, and you can run on local successfully, th
8787

8888
5. When you are running the application for the first time, It will take some time initially to download the image and install the dependencies
8989

90-
## Verification
91-
92-
See `Verification.md`
90+
You can also head into `docker-pgsql-es` folder and run `docker-compose up -d` to have docker instances of pgsql and elasticsearch to use with the api

VERIFICATION.md

Lines changed: 0 additions & 105 deletions
This file was deleted.

docker-pgsql-es/docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: '3'
2+
services:
3+
postgres:
4+
image: "postgres:12.4"
5+
volumes:
6+
- database-data:/var/lib/postgresql/data/
7+
ports:
8+
- "5432:5432"
9+
environment:
10+
POSTGRES_PASSWORD: ${DB_PASSWORD}
11+
POSTGRES_USER: ${DB_USERNAME}
12+
POSTGRES_DB: ${DB_NAME}
13+
esearch:
14+
image: elasticsearch:7.7.1
15+
container_name: ubahn-data-processor-es_es
16+
ports:
17+
- "9200:9200"
18+
environment:
19+
- discovery.type=single-node
20+
volumes:
21+
database-data:

docker/docker-compose.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
# TODO - Update BEFORE merge
2-
31
version: '3'
42
services:
5-
postgres:
6-
image: "postgres:13.1"
7-
volumes:
8-
- database-data:/var/lib/postgresql/data/
9-
ports:
10-
- "5432:5432"
11-
environment:
12-
POSTGRES_PASSWORD: ${DB_PASSWORD}
13-
POSTGRES_USER: ${DB_USERNAME}
14-
POSTGRES_DB: ${DB_NAME}
15-
esearch:
16-
image: elasticsearch:7.7.1
17-
container_name: ubahn-data-processor-es_es
3+
ubahn_api:
4+
image: ubahn_api:latest
5+
build:
6+
context: ../
7+
dockerfile: docker/Dockerfile
8+
env_file:
9+
- api.env
1810
ports:
19-
- "9200:9200"
20-
environment:
21-
- discovery.type=single-node
22-
volumes:
23-
database-data:
11+
- "3001:3001"

docs/swagger.yaml

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -71,159 +71,12 @@ paths:
7171
description: "Enrich all child resources under the user"
7272
required: false
7373
type: "boolean"
74-
- name: "skill[]"
75-
in: "query"
76-
type: "array"
77-
description: "The skill name to filter users with. Specify multiple times to provide multiple values"
78-
items:
79-
type: "string"
80-
collectionFormat: multi
81-
- name: "achievement[]"
82-
in: "query"
83-
type: "array"
84-
description: "The achievement name to filter users with. Specify multiple times to provide multiple values"
85-
items:
86-
type: "string"
87-
collectionFormat: multi
88-
- name: "location[]"
89-
in: "query"
90-
type: "array"
91-
description: "The location name to filter users with. Specify multiple times to provide multiple values. `location` here is an attribute of the user"
92-
items:
93-
type: "string"
94-
collectionFormat: multi
95-
- name: "isAvailable"
96-
in: "query"
97-
type: "boolean"
98-
description: "`true` corresponds to users that are available. `false` corresponds to users that are not available. `isAvailable` here is an attribute of the user"
99-
items:
100-
type: "string"
101-
collectionFormat: multi
102-
- name: "orderBy"
103-
in: "query"
104-
type: "string"
105-
description: "Sort order"
106-
enum: ["name", "location", "isAvailable"]
10774
- name: "roleId"
10875
in: "query"
10976
description: "Filter by user roleId"
11077
required: false
11178
type: "string"
11279
format: "UUID"
113-
- name: "userSkill.skillId"
114-
in: "query"
115-
required: false
116-
type: "string"
117-
format: "UUID"
118-
- name: "userSkill.metricValue"
119-
in: "query"
120-
required: false
121-
type: "string"
122-
- name: "userSkill.certifierId"
123-
in: "query"
124-
required: false
125-
type: "string"
126-
format: "UUID"
127-
- name: "userSkill.certifiedDate"
128-
in: "query"
129-
required: false
130-
type: "string"
131-
- name: "skill.skillProviderId"
132-
in: "query"
133-
required: false
134-
type: "string"
135-
format: "UUID"
136-
- name: "skill.name"
137-
in: "query"
138-
required: false
139-
type: "string"
140-
- name: "skill.externalId"
141-
in: "query"
142-
required: false
143-
type: "string"
144-
- name: "skill.uri"
145-
in: "query"
146-
required: false
147-
type: "string"
148-
- name: "skillProvider.name"
149-
in: "query"
150-
required: false
151-
type: "string"
152-
- name: "userRole.roleId"
153-
in: "query"
154-
required: false
155-
type: "string"
156-
format: "UUID"
157-
- name: "role.name"
158-
in: "query"
159-
required: false
160-
type: "string"
161-
- name: "externalProfile.organizationId"
162-
in: "query"
163-
required: false
164-
type: "string"
165-
format: "UUID"
166-
- name: "externalProfile.uri"
167-
in: "query"
168-
required: false
169-
type: "string"
170-
- name: "organization.name"
171-
in: "query"
172-
required: false
173-
type: "string"
174-
- name: "achievement.achievementProviderId"
175-
in: "query"
176-
required: false
177-
type: "string"
178-
format: "UUID"
179-
- name: "achievement.name"
180-
in: "query"
181-
required: false
182-
type: "string"
183-
- name: "achievement.uri"
184-
in: "query"
185-
required: false
186-
type: "string"
187-
- name: "achievement.certifierId"
188-
in: "query"
189-
required: false
190-
type: "string"
191-
format: "UUID"
192-
- name: "achievement.certifiedDate"
193-
in: "query"
194-
required: false
195-
type: "string"
196-
- name: "achievementProvider.name"
197-
in: "query"
198-
required: false
199-
type: "string"
200-
- name: "userAttribute.attributeId"
201-
in: "query"
202-
required: false
203-
type: "string"
204-
format: "UUID"
205-
- name: "userAttribute.value"
206-
in: "query"
207-
required: false
208-
type: "string"
209-
- name: "attribute.attributeGroupId"
210-
in: "query"
211-
required: false
212-
type: "string"
213-
format: "UUID"
214-
- name: "attribute.name"
215-
in: "query"
216-
required: false
217-
type: "string"
218-
- name: "attributeGroup.name"
219-
in: "query"
220-
required: false
221-
type: "string"
222-
- name: "attributeGroup.organizationId"
223-
in: "query"
224-
required: false
225-
type: "string"
226-
format: "UUID"
22780
responses:
22881
"200":
22982
description: "OK - the request was successful"

scripts/db/dumpDbToEs.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// TODO - Update BEFORE merge
2-
31
const _ = require('lodash')
42
const sequelize = require('../../src/models/index')
53
const dbHelper = require('../../src/common/db-helper')

0 commit comments

Comments
 (0)