Skip to content

Commit

Permalink
Merge pull request #350 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 3, 2024
2 parents 32024a3 + 5dc0a94 commit ec62f78
Show file tree
Hide file tree
Showing 18 changed files with 3,148 additions and 9 deletions.
819 changes: 819 additions & 0 deletions documentation/occupi-docs/pages/api-documentation/analytics.mdx

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions documentation/occupi-docs/pages/api-documentation/api-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ The API also allows you to retrieve information about these resources.
- [Delete Room Image](#DeleteRoomImage)
- [Add Room](#AddRoom)
- [Available slots](#AvailableSlots)
- [Toggle on site](#ToggleOnSite)

## Base URL

The base URL for the Occupi API is `https://occupi.tech`, `https://dev.occupi.tech` or `http://localhost:8080` if you are in develop mode.

## Api

Expand Down Expand Up @@ -1038,4 +1043,49 @@ or

- **Code:** 400

- **Content:** `{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Invalid JSON payload"} }`

### Toggle On Site

This endpoint is used to toggle the on site status of a user in the Occupi system. That is whether or not they are in the office
Just some notes about this endpoint:
- If the user is on site, they cannot become on site again and vice versa
- If the user tries to toggle their status outside of office hours (8am - 5pm)Monday to Friday, they will not be able to do so
- If the user forgets to toggle their status, the system will automatically limit their hours for the day they had forgotten to toggle their status to 5pm

- **URL**

`/api/toggle-onsite`

- **Method**

`PUT`

- **Request Body**

- **Content**

```json copy
{
"email": "abcd@gmail.com", // this is not explicitly required as it can be determined by the system
"onSite": "Yes" // required, can be "Yes" or "No" (exact match)
}
```

**Success Response**

- **Code:** 200

- **Content:** `{ "status": 200, "message": "Successfully toggled on site status!", "data": null }`

**Error Response**

- **Code:** 500

- **Content:** `{ "status": 500, "message": "Internal server error", "error": {"code":"INTERNAL_SERVER_ERROR","details":null,"message":"Internal server error"} }`

**Error Response**

- **Code:** 400

- **Content:** `{ "status": 400, "message": "Invalid request payload", "error": {"code":"BAD_REQUEST","details":null,"message":"Invalid JSON payload"} }`
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ The auth endpoint is used to authenticate a user and get a token to access the A
- [Reset Password Mobile Login](#reset-password-mobile-login)
- [Reset Password Mobile Admin Login](#reset-password-mobile-admin-login)

## Base URL

The base URL for the Occupi API is `https://occupi.tech`, `https://dev.occupi.tech` or `http://localhost:8080` if you are in develop mode.

## Authentication

The authentication endpoints are used to register, login, login-admin, logout, and verify users. Only POST requests are used for these endpoints.
Expand Down
1 change: 1 addition & 0 deletions occupi-backend/cmd/occupi-backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func main() {
SetEnvironment(*env).
InitializeConfig().
SetupLogger().
SetUpTimeZone().
CreateAppSession().
StartConsumer().
SetupRouter().
Expand Down
9 changes: 9 additions & 0 deletions occupi-backend/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const (
AzurePFPContainerName = "AZURE_PFP_CONTAINER_NAME"
AzureRoomsContainerName = "AZURE_ROOMS_CONTAINER_NAME"
AzureAccountKey = "AZURE_ACCOUNT_KEY"
TimeZone = "TIMEZONE"
)

// init viper
Expand Down Expand Up @@ -567,3 +568,11 @@ func GetAzureAccountKey() string {
}
return accountKey
}

func GetTimeZone() string {
timeZone := viper.GetString(TimeZone)
if timeZone == "" {
timeZone = "TIMEZONE"
}
return timeZone
}
Loading

0 comments on commit ec62f78

Please sign in to comment.