Skip to content
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

[BE] rename statistic to statistics #2634

Merged
merged 6 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/certbot-update-cert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
- name: Update certs
run: |
docker-compose pull
docker-compose run --rm certbot renew --allow-subset-of-names
docker-compose restart brn_fe_with_tls
docker compose pull
docker compose run --rm certbot renew --allow-subset-of-names
docker compose restart brn_fe_with_tls
docker image prune -af
2 changes: 1 addition & 1 deletion .github/workflows/create_cert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
API_GITHUB_TOKEN: ${{ secrets.API_GITHUB_TOKEN }}
- name: Create cert
run: |
docker-compose run --rm certbot certonly --webroot --webroot-path=/var/www/html --email brainupproject@yandex.ru -d brainup.fun
docker compose run --rm certbot certonly --webroot --webroot-path=/var/www/html --email brainupproject@yandex.ru -d brainup.fun
19 changes: 4 additions & 15 deletions .github/workflows/docker-build-push-redeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ jobs:
name: brainup/brn-backend
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
build_and_publish_frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish to Registry brainup/brn-frontend
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: brainup/brn-frontend
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: Dockerfile_frontend
build_and_publish_frontend_with_tls:
runs-on: ubuntu-latest
steps:
Expand All @@ -39,7 +28,7 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}
dockerfile: Dockerfile_frontend_with_tls
redeploy_instance:
needs: [ build_and_publish_backend, build_and_publish_frontend, build_and_publish_frontend_with_tls]
needs: [ build_and_publish_backend, build_and_publish_frontend_with_tls]
runs-on: ${{ matrix.runners }}
strategy:
matrix:
Expand Down Expand Up @@ -67,10 +56,10 @@ jobs:
# Link 2: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsif
- name: Redeploy backend
run: |
docker-compose pull
docker-compose up -d --no-deps brn
docker compose pull
docker compose up -d --no-deps brn
- name: Redeploy frontend selectel
if: matrix.runners == 'selectel'
run: docker-compose up -d --no-deps brn_fe_with_tls
run: docker compose up -d --no-deps brn_fe_with_tls
- name: Remove old images
run: docker image prune -af
6 changes: 3 additions & 3 deletions .github/workflows/instances-redeploy.yml_tmp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ jobs:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
- name: Redeploy application
run: |
docker-compose pull
docker-compose down
docker-compose up -d
docker compose pull
docker compose down
docker compose up -d
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:jdk17 as builder
FROM gradle:jdk17 AS builder

WORKDIR /brn
ADD . /brn
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile_frontend
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12 as build-frontend
FROM node:12 AS build-frontend
ARG FIREBASE_PROJECT_ID
ENV FIREBASE_PROJECT_ID ${FIREBASE_PROJECT_ID:-}
ARG FIREBASE_AUTH_DOMAIN
Expand All @@ -10,7 +10,7 @@ WORKDIR /src
RUN yarn
RUN node node_modules/ember-cli/bin/ember deploy production

FROM node:12 as build-frontend-angular
FROM node:12 AS build-frontend-angular
COPY frontend-angular/ /src/
WORKDIR /src
RUN npm ci
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile_frontend_with_tls
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM node:12 as build-frontend
FROM node:12 AS build-frontend
COPY frontend/ /src/
WORKDIR /src
RUN yarn
RUN node node_modules/ember-cli/bin/ember deploy production

FROM node:12 as build-frontend-angular
FROM node:12 AS build-frontend-angular
COPY frontend-angular/ /src/
WORKDIR /src
RUN npm ci
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ docker_clean_app_images: stop
docker rmi brn_test db_brn brn

docker_clean_test_containers:
docker-compose -f docker-compose-unit-test.yml down
docker compose -f docker-compose-unit-test.yml down

docker_unit_test: clean
docker-compose -f docker-compose-unit-test.yml up --build --force-recreate --exit-code-from brn-test
docker compose -f docker-compose-unit-test.yml up --build --force-recreate --exit-code-from brn-test

start:
docker-compose up --build --force-recreate
docker compose up --build --force-recreate

stop:
docker-compose down
docker compose down

restart: clean stop start
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Product Vision https://github.com/Brain-up/brn/wiki/Product-Vision.
- Scientific basis of the project: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6417420/

## Published ARTICLES about our project
- https://aw.club/global/en/blog/volunteer/brain-up?utm_source=telegram&utm_medium=social&utm_campaign=ongoing 11.08.2022 (russian, english) will be fixed soon
- https://wearecommunity.io/communities/community-platform/articles/753 01.12.2020 russian
- https://habr.com/ru/company/epam_systems/blog/530824 01.12.2020
- https://anywhere.epam.com/volunteer/pages-1/brainApp.html (will be fixed soon) 05.05.2020
Expand Down Expand Up @@ -128,11 +127,11 @@ Note that if you are using IntelliJ, you may want to use version 2019.2 and late
(back-end part and front-end parts, but it is rather slow. it is better to use GitPod)
From console, from project's folder, execute:
```bash
docker-compose up --build
docker compose up --build
```
Alternatively, use daemon mode (no console output):
```bash
docker-compose up --build -d
docker compose up --build -d
```
Local REST API will be accessible at http://localhost:8081/api/swagger-ui.html
Public is always here https://brainup.site/admin/swagger (login with ADMIN role user)
Expand Down
15 changes: 7 additions & 8 deletions docker-compose-run.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
db_brn:
image: postgres:13
Expand Down Expand Up @@ -33,13 +32,13 @@ services:
- firebase_config_json
depends_on:
- db_brn
brn_fe:
image: brainup/brn-frontend:latest
container_name: brn_fe
# ports:
# - 80:80
depends_on:
- brn
# brn_fe:
# image: brainup/brn-frontend:latest
# container_name: brn_fe
# # ports:
# # - 80:80
# depends_on:
# - brn
brn_fe_with_tls:
image: brainup/brn-frontend-with-tls:latest
container_name: brn_fe_with_tls
Expand Down
1 change: 0 additions & 1 deletion docker-compose-unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
db:
image: postgres:13
Expand Down
1 change: 0 additions & 1 deletion docker-compose-with-secret.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
db_brn:
image: postgres:13
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
services:
db_brn:
container_name: db_brn
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/com/epam/brn/config/FirebaseConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ class FirebaseConfig {
fun firebaseApp(): FirebaseApp {
if (FirebaseApp.getApps().isEmpty()) {
val refreshToken = FileInputStream(firebaseCredentialsPath)

val options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(refreshToken))
.build()

FirebaseApp.initializeApp(options)
}
return FirebaseApp.getInstance()
Expand Down
13 changes: 7 additions & 6 deletions src/main/kotlin/com/epam/brn/config/GoogleCloudConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.google.auth.oauth2.GoogleCredentials
import com.google.cloud.storage.Storage
import com.google.cloud.storage.StorageOptions
import com.google.common.collect.Lists
import org.apache.logging.log4j.kotlin.logger
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.context.annotation.Configuration
Expand All @@ -20,8 +19,6 @@ class GoogleCloudConfig(
@Value("\${cloud.expireAfterDuration}") expireAfterDuration: String
) {

private val log = logger()

@Value("\${google.bucketName}")
val bucketName: String = ""
@Value("\${google.bucketLink}")
Expand All @@ -31,11 +28,15 @@ class GoogleCloudConfig(
final var storage: Storage?

init {
val credentials = GoogleCredentials.fromStream(FileInputStream(credentialsPath))
val credentials = GoogleCredentials
.fromStream(FileInputStream(credentialsPath))
.createScoped(Lists.newArrayList(credentialScope))
storage =
StorageOptions.newBuilder().setCredentials(credentials).setProjectId(projectId)
.build().getService()
StorageOptions.newBuilder()
.setCredentials(credentials)
.setProjectId(projectId)
.build()
.service
expireAfter = Duration.parse(expireAfterDuration)
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/epam/brn/config/SwaggerConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SwaggerConfig {
.contact(
Contact()
.name("Elena.Moshnikova")
.url("https://www.epam.com/")
.url("https://t.me/ElenaLovesSpb")
.email("brainupproject@yandex.ru")
)

Expand Down
14 changes: 8 additions & 6 deletions src/main/kotlin/com/epam/brn/service/AudiometryHistoryService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ class AudiometryHistoryService(
val headphonesFromUser = getSpecificHeadphonesFromCurrentUser(currentUser.headphones, request.headphones)
val audiometryHistory = request.toEntity(currentUser, audiometryTask, headphonesFromUser)
val savedAudiometryHistory = audiometryHistoryRepository.save(audiometryHistory)
if (!request.sinAudiometryResults.isNullOrEmpty()) {
if (!request.sinAudiometryResults.isNullOrEmpty())
request.sinAudiometryResults!!.forEach { (frequency, sound) ->
sinAudiometryResultRepository.save(
SinAudiometryResult(frequency = frequency, soundLevel = sound, audiometryHistory = savedAudiometryHistory)
SinAudiometryResult(
frequency = frequency,
soundLevel = sound,
audiometryHistory = savedAudiometryHistory
)
)
}
}
return savedAudiometryHistory.id!!
}

private fun getSpecificHeadphonesFromCurrentUser(headphones: MutableSet<Headphones>, headphonesId: Long?) =
headphones.find() { entity ->
entity.id == headphonesId
} ?: throw IllegalArgumentException("Current user has ho headphones with id=$headphonesId")
headphones.find { entity -> entity.id == headphonesId }
?: throw IllegalArgumentException("Current user has ho headphones with id=$headphonesId")
}
3 changes: 1 addition & 2 deletions src/main/kotlin/com/epam/brn/service/TokenHelperUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ class TokenHelperUtils {
fun getBearerToken(request: HttpServletRequest): String? {
var bearerToken: String? = null
val authorization = request.getHeader("Authorization")
if (StringUtils.hasText(authorization) && authorization.startsWith("Bearer ")) {
if (StringUtils.hasText(authorization) && authorization.startsWith("Bearer "))
bearerToken = authorization.substring(7)
}
return bearerToken
}
}
2 changes: 1 addition & 1 deletion src/main/resources/initFiles/series_sentences_ru.csv
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ level,code,exerciseName,orderNumber,words
12,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(мудрая великая);(волшебница фея);(прощает поёт);();())
13,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(великодушный трусливый);(рыцарь кузнец);(спрашивает отвечает);();())
13,sentence_with_3_words,Пойми предложение из 3 слов,2,(();(смелая храбрая);(муха лягушка);(сражается борется);();())
14,sentence_with_3_words,Пойми предложение из 3 слов,2,((три семь);();(поросёнка волчонка);(строят дуют);();())
14,sentence_with_3_words,Пойми предложение из 3 слов,2,((три четыре);();(поросёнка волчонка);(строят дуют);();())
15,sentence_with_3_words,Пойми предложение из 3 слов,2,((двенадцать семнадцать);();(лебедей червяков);(летят ползут);();())
16,sentence_with_3_words,Пойми предложение из 3 слов,2,((три два);();(дядюшки зайца);(бегут стоят);();())
17,sentence_with_3_words,Пойми предложение из 3 слов,2,((три четыре);();(зайчонка лисы);(пищат шумят);();())
Expand Down
Loading