feat: DataProperties
This commit is contained in:
parent
2f161d3481
commit
8d03c86c8f
5 changed files with 39 additions and 14 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,3 +3,6 @@ target/
|
||||||
### IntelliJ IDEA ###
|
### IntelliJ IDEA ###
|
||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
|
# local files
|
||||||
|
data/
|
||||||
|
|
36
readme.md
36
readme.md
|
@ -1,7 +1,8 @@
|
||||||
# Large file reading challenge
|
# Large file reading challenge
|
||||||
|
|
||||||
Welcome in the recruitment challenge.
|
Welcome in the recruitment challenge.
|
||||||
Write an application that, at the endpoint specified by you, returns the yearly average temperatures for a given city in the format array of objects with the following fields: year, averageTemperature.
|
Write an application that, at the endpoint specified by you, returns the yearly average temperatures for a given city in
|
||||||
|
the format array of objects with the following fields: year, averageTemperature.
|
||||||
|
|
||||||
## Assumptions
|
## Assumptions
|
||||||
|
|
||||||
|
@ -10,33 +11,40 @@ Write an application that, at the endpoint specified by you, returns the yearly
|
||||||
- The content of the source file may change during the application's running
|
- The content of the source file may change during the application's running
|
||||||
|
|
||||||
## Example source file
|
## Example source file
|
||||||
[example_file.csv](example_file.csv)
|
|
||||||
|
|
||||||
|
[example_file.csv](example_file.csv)
|
||||||
|
|
||||||
## Response
|
## Response
|
||||||
|
|
||||||
### Schema
|
### Schema
|
||||||
|
|
||||||
[response_schema](schema/response.json)
|
[response_schema](schema/response.json)
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"year": "2021",
|
"year": "2021",
|
||||||
"averageTemperature": 12.1
|
"averageTemperature": 12.1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"year": "2022",
|
"year": "2022",
|
||||||
"averageTemperature": 11.1
|
"averageTemperature": 11.1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"year": "2023",
|
"year": "2023",
|
||||||
"averageTemperature": 14.1
|
"averageTemperature": 14.1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
| property | description | default |
|
||||||
|
|---------------|--------------------------------|-----------------------|
|
||||||
|
| data.file-url | path to file with temperatures | data/temperatures.csv |
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Temperature statistics endpoint: `/api/temperatures/{city}`
|
Temperature statistics endpoint: `/api/temperatures/{city}`
|
||||||
|
|
|
@ -2,8 +2,12 @@ package eu.ztsh.lfr;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
@EnableConfigurationProperties
|
||||||
|
@ConfigurationPropertiesScan
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
8
src/main/java/eu/ztsh/lfr/config/DataProperties.java
Normal file
8
src/main/java/eu/ztsh/lfr/config/DataProperties.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package eu.ztsh.lfr.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
@ConfigurationProperties("data")
|
||||||
|
public record DataProperties(String fileUrl) {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
data:
|
||||||
|
file-url: data/temperatures.csv
|
Loading…
Add table
Add a link
Reference in a new issue