StatisticsController - adkuba/TL-backend GitHub Wiki
- Homepage view
- Get all statistics
- Get all devices
- Create review
- Get locations
- Get views
- Get profile locations
- Get profile views
- Create backup
- Restore backup
- Update geolocation
Endpoints
Homepage view
Adds device and localization info about homepage view, based on HttpServletRequest.
Path
POST /api/statistics/public
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | statistics added |
Get all statistics
Path
GET /api/statistics/all
Requires ADMIN role
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | statistics returned |
List of Statistics
Statistics
{
#all numbers long
"id": "aaaaeeee", #autogenerated
"totalTimelinesViews": 3645,
"mainPageViews": 345,
"numberOfUsers": 31, #new users this date
"activeUsers": 34,
"profileViews": 355,
"day": 2020-02-21,
"devices": [ #map
{
"deviceId",
234 #Number of views on that day from deviceId
}
]
}
Get all devices
Path
GET /api/statistics/all-devices
Requires ADMIN role
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | devices returned |
List of DeviceInfo
Create review
Path
POST /api/statistics/public/review
Request body
Review
Parameter | Type | Description |
---|---|---|
username |
String | user's username |
opinion |
String | user's review |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | review created |
Get locations
Returns timeline's views locations.
Path
GET /api/statistics/timeline/{id}
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timeline's statistics location returned |
400 Bad Request | error |
Returns List<StatResponse> with null days.
Stat Response
{
"date": 2020-12-21, #localDate
"location": "Poland",
"number": 234 #long
}
Get views
Returns number of views for timeline each day.
Path
GET /api/statistics/timeline-views/{id}
Path variable
Variable | Type | Description |
---|---|---|
id |
String | timeline's id |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | timeline's statistics views number returned |
400 Bad Request | error |
Returns List<StatResponse> with null locations.
Get profile locations
Returns profile's views location.
Path
GET /api/statistics/profile-locations/{username}
Path variable
Variable | Type | Description |
---|---|---|
username |
String | profile's username |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | profile's statistics views location returned |
400 Bad Request | error |
Returns List<StatResponse> with null days.
Get profile views
Returns profile's views number each day.
Path
GET /api/statistics/profile-views/{username}
Path variable
Variable | Type | Description |
---|---|---|
username |
String | profile's username |
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | profile's statistics views number returned |
400 Bad Request | error |
Returns List<StatResponse> with null locations.
Create backup
Path
GET /api/statistics/create-backup
Requires ADMIN role
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | backup created |
Saves whole mongo database (every document in separate json files) to Google Cloud Storage.
Restore backup
Path
GET /api/statistics/restore-backup
Requires ADMIN role
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | data restored from backup |
Deletes all objects in mongodb database and restores data from backup in Google Cloud Storage.
Update geolocation
Updates all location data in statistics document based on each object ip field. Useful when changing "ip to location" convrter.
Path
GET /api/statistics/update-geolocation
Requires ADMIN role
Response
HTTP Status Code | Scenario |
---|---|
201 Ok | geolocalization data updated |