Skip to content

Commit

Permalink
Merge pull request #212 from AlexTelon/refactoring-database-structure
Browse files Browse the repository at this point in the history
Refactoring database structure
  • Loading branch information
loan21xw authored Oct 6, 2023
2 parents c0ed35d + 5be3bf4 commit 51bf2f7
Show file tree
Hide file tree
Showing 61 changed files with 4,302 additions and 2,942 deletions.
42 changes: 16 additions & 26 deletions .github/workflows/backend-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,43 +42,33 @@ jobs:
envkey_USER_POOL: ${{ secrets.USER_POOL }}
envkey_USER_POOL_ID: ${{ secrets.USER_POOL_ID }}
envkey_USER_POOL_SECRET: ${{ secrets.USER_POOL_SECRET }}
envkey_DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
envkey_DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
envkey_DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
envkey_DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
envkey_DATABASE_NAME: "UNNEEDED"
envkey_DATABASE_USERNAME: "UNNEEDED"
envkey_DATABASE_PASSWORD: "UNNEEDED"
envkey_DATABASE_HOST: "UNNEEDED"
envkey_KLARNA_TOKEN: ${{ secrets.KLARNA_TOKEN }}
directory: backend-app/

# # Runs sequentially to starting the back-end app
# - name: Install requirements
# # Installs the requirements
# run: |
# export PYTHONPATH=.
# pip install -r ./test/requirements.txt

# Run the backend app
# & is used to signal that this task will keep running, as to not get stuck on this step
- name: launch docker container
run: |
docker-compose build
docker-compose up &
# Runs sequentially to starting the back-end app
- name: Install requirements
# Installs the requirements
run: |
export PYTHONPATH=.
pip install -r ./test/requirements.txt
docker-compose up --build -d
# Executes the tests within the /backend_tests folder
- name: Run PyTest
run: python -m pytest ./test/backend_tests --junit-xml=report.xml

- name: Install Jest
run: |
npm i jest
npm i jest-junit
- name: Install axios
run: |
npm i axios
# - name: Run PyTest
# run: python -m pytest ./test/backend_tests --junit-xml=report.xml

- name: Run unit tests
run:
npm test --prefix ./backend-app
run: |
docker exec flexicharge-backend "npm" "test"
# Displays a summary and overlook of test cases
- name: Publish test result
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ Needed to start app.
- updateTransactionPayment(transactionId: int, paymentId: int))
- updateTransactionMeter(transactionId: int, meterValue: int))
```
- **databaseInterfaceReservations**
```
- addReservation(chargerId: int, userId: int, start: int, stop: int, function(errors, reservation))
- getReservation(reservationId: int, function(errors, reservation))
- getReservationForUser(userId: int, function(errors, reservations))
- getReservationForCharger(chargerId: int, function(errors, reservations))
- removeReservation(reservationId: int, function(errors, reservationRemoved: bool))
```



Expand Down
121 changes: 31 additions & 90 deletions backend-app/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -558,29 +558,21 @@ paths:
schema:
type: object
properties:
userID:
type: string
example: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
chargerID:
type: integer
example: 100001
example: 100000
isKlarnaPayment:
type: boolean
example: true
pricePerKwh:
type: number
example: 333
security:
- bearerAuth: []
responses:
'201':
description: Successful response
content:
application/json:
schema:
type: object
properties:
transactionID:
type: integer
example: 9999
$ref: '#/components/schemas/Transaction'
'400':
description: Error message
'500':
Expand All @@ -591,13 +583,16 @@ paths:
name: transactionID
schema:
type: integer
example: 100000
required: true
put:
tags:
- Transactions
summary: Start a transaction
description: |-
Starts a transaction
security:
- bearerAuth: []
responses:
'200':
description: Successful response
Expand All @@ -615,13 +610,16 @@ paths:
name: transactionID
schema:
type: integer
example: 100000
required: true
get:
tags:
- Transactions
summary: Get status of a transaction
description: |-
Gets the status of a transaction
security:
- bearerAuth: []
responses:
'200':
description: Successful response
Expand All @@ -639,13 +637,16 @@ paths:
name: transactionID
schema:
type: integer
example: 100000
required: true
put:
tags:
- Transactions
summary: Stop a transaction
description: |-
Stops a transaction
security:
- bearerAuth: []
responses:
'200':
description: Successful response
Expand All @@ -657,79 +658,6 @@ paths:
description: Error message
'500':
description: Error message
/transactions/payment/{transactionID}:
parameters:
- in: path
name: transactionID
schema:
type: integer
required: true
put:
tags:
- Transactions
summary: Update payment
requestBody:
content:
application/json:
schema:
type: object
example:
transactionID: '1'
paymentId: '2'
responses:
'200':
description: Successful response
content:
application/json: {}
/transactions/chargingStatus/{transactionID}:
parameters:
- in: path
name: transactionID
schema:
type: integer
required: true
put:
tags:
- Transactions
summary: Update transaction status
requestBody:
content:
application/json:
schema:
type: object
example:
kwhTransfered: 1
currentChargePercentage: 1
responses:
'201':
description: Successful response
content:
application/json: {}
'404':
description: Error message
'500':
description: Error message
/transactions/session:
post:
tags:
- Transactions
requestBody:
content:
application/json:
schema:
type: object
example:
userID: 1
chargerID: 1
responses:
'201':
description: Successful response
content:
application/json: {}
'400':
description: Error message
'500':
description: Error message
/transactions/userTransactions/{userID}:
parameters:
- in: path
Expand All @@ -741,11 +669,17 @@ paths:
tags:
- Transactions
summary: Transaction by userID
security:
- bearerAuth: []
responses:
'200':
description: Successful response
content:
application/json: {}
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Transaction'
/transactions/chargerTransactions/{chargerID}:
parameters:
- in: path
Expand All @@ -757,11 +691,17 @@ paths:
tags:
- Transactions
summary: Transaction by transactions
security:
- bearerAuth: []
responses:
'200':
description: Successful response
content:
application/json: {}
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Transaction'
/reservations/{reservationID}:
parameters:
- in: path
Expand Down Expand Up @@ -1177,7 +1117,7 @@ components:
properties:
transactionID:
type: integer
example: 1
example: 9999
isKlarnaPayment:
type: boolean
example: false
Expand All @@ -1202,7 +1142,7 @@ components:
session_id:
type: string
example: null
client_token:
klarna_consumer_token:
type: string
example: null
paymentConfirmed:
Expand All @@ -1213,9 +1153,10 @@ components:
example: 1
chargerID:
type: integer
example: 100002
example: 100000

securitySchemes:
bearerAuth:
type: http
scheme: bearer

Loading

0 comments on commit 51bf2f7

Please sign in to comment.