Skip to content

Commit

Permalink
Merge pull request #355 from COS301-SE-2024/feat/backend/deep-user-ba…
Browse files Browse the repository at this point in the history
…sed-analytics

Feat/backend/deep user based analytics
  • Loading branch information
waveyboym authored Sep 9, 2024
2 parents 48362e4 + a9f051b commit e7adad4
Show file tree
Hide file tree
Showing 11 changed files with 1,583 additions and 617 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test-build-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
- name: 🧪 Run tests
run: |
gotestsum --format testname --junitfile tmp/test-results/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
gotestsum --format testname --junitfile tmp/test-results/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
- name: 📋 Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- name: 🧪 Run tests
run: |
gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
- name: 📋 Upload coverage reports to Codecov
uses: codecov/[email protected]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ The most active employee endpoint is used to get the most active employee in the

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -441,7 +440,6 @@ The least active employee endpoint is used to get the least active employee in t

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -496,7 +494,6 @@ The workers hours endpoint is used to get the hours of all the workers in the of

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -553,7 +550,6 @@ The workers average hours endpoint is used to get the average hours of all the w

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -610,7 +606,6 @@ The workers work ratio endpoint is used to get the work ratio of all the workers

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -666,7 +661,6 @@ The workers peak office hours endpoint is used to get the peak office hours of a

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -722,7 +716,6 @@ The workers arrival departure average endpoint is used to get the arrival depart

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down Expand Up @@ -778,7 +771,6 @@ The workers in office rate endpoint is used to get the in office rate of all the

```json
{
"email": "abcd@gmail", // this is optional
"timeFrom": "2021-01-01T00:00:00.000Z", // this is optional and will default to 1970-01-01T00:00:00.000Z
"timeTo": "2021-01-01T00:00:00.000Z", // this is optional and will default to current date
"limit": 50, // this is optional and will default to 50
Expand Down
8 changes: 4 additions & 4 deletions occupi-backend/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ func GetCentrifugoPort() string {
}

func GetCentrifugoSecret() string {
secret := viper.GetString(CentrifugoSC)
if secret == "" {
secret = "CENTRIFUGO_SECRET"
csc := viper.GetString(CentrifugoSC)
if csc == "" {
csc = "CENTRIFUGO_SECRET"
}
return secret
return csc
}

// gets the config license as defined in the config.yaml file
Expand Down
8 changes: 4 additions & 4 deletions occupi-backend/occupi.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ if "%1 %2" == "run dev" (
gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v ./tests/...
exit /b 0
) else if "%1 %2" == "test codecov" (
gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
exit /b 0
) else if "%1 %2" == "report codecov" (
gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
exit /b 0
) else if "%1" == "lint" (
golangci-lint run
Expand All @@ -55,8 +55,8 @@ echo docker build : docker compose -f docker-compose.localdev.yml build
echo docker up : docker compose -f docker-compose.localdev.yml up -d
echo test : gotestsum --format testname -- -v ./tests/...
echo report : gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v ./tests/...
echo test codecov : gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
echo report codecov : gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
echo test codecov : gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
echo report codecov : gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
echo lint : golangci-lint run
echo convert report : python reports/convert_report.py reports.json -o allure-results
echo help : Show this help message
Expand Down
8 changes: 4 additions & 4 deletions occupi-backend/occupi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ print_help() {
echo " build prod -> go build cmd/occupi-backend/main.go"
echo " test -> gotestsum --format testname -- -v ./tests/..."
echo " report -> gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v ./tests/..."
echo " test codecov -> gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out"
echo " report codecov -> gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out"
echo " test codecov -> gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out"
echo " report codecov -> gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out"
echo " lint -> golangci-lint run"
echo " decrypt env -> cd scripts && chmod +x decrypt_env_variables.sh && ./decrypt_env_variables.sh"
echo " encrypt env -> cd scripts && chmod +x encrypt_env_variables.sh && ./encrypt_env_variables.sh"
Expand All @@ -31,9 +31,9 @@ elif [ "$1" = "test" ]; then
elif [ "$1" = "report" ]; then
gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v ./tests/...
elif [ "$1" = "test" ] && [ "$2" = "codecov" ]; then
gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
gotestsum --format testname -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
elif [ "$1" = "report" ] && [ "$2" = "codecov" ]; then
gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
gotestsum --format testname --junitfile reports/gotestsum-report.xml -- -v -coverpkg=github.com/COS301-SE-2024/occupi/occupi-backend/pkg/analytics,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/authenticator,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/cache,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/database,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/middleware,github.com/COS301-SE-2024/occupi/occupi-backend/pkg/utils ./tests/... -coverprofile=coverage.out
elif [ "$1" = "lint" ]; then
golangci-lint run
elif [ "$1" = "decrypt" ] && [ "$2" = "env" ]; then
Expand Down
Loading

0 comments on commit e7adad4

Please sign in to comment.