-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor code for readability and consistency
Several classes across various modules have been refactored to improve readability by adding line breaks to long functions and making indentation consistent. No functionality changes have been introduced. In addition, unnecessary imports have been removed improving overall cleanliness of the code.
- Loading branch information
Showing
32 changed files
with
812 additions
and
764 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[{*.kt,*.kts}] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,46 @@ | ||
# Restaurants | ||
|
||
This module is responsible for fetching restaurant items from USP (through [USP Restaurant API][1]) and persist them in a PostgresQL table, while also providing an API for the retrieval of these items. | ||
This module is responsible for fetching restaurant items from USP (through [USP Restaurant API][1]) and persist them in | ||
a PostgresQL table, while also providing an API for the retrieval of these items. | ||
|
||
## Fetching from USP | ||
|
||
We trust the [USP Restaurant API][1] definitions, and with them the [USPRestaurantItemRepository][3] is able to fetch items from USP's api. | ||
We trust the [USP Restaurant API][1] definitions, and with them the [USPRestaurantItemRepository][3] is able to fetch | ||
items from USP's api. | ||
|
||
### Parsing the menu | ||
|
||
It's important for this application to parse all values, as clients are going to expect a smarter output instead of just the menus (otherwise, why would this module be necessary?). For that we have the [MenuParsers][4]. We try with our best effort to parse the menus, however there is some difficulty as restaurants won't always report items in the same way. | ||
It's important for this application to parse all values, as clients are going to expect a smarter output instead of just | ||
the menus (otherwise, why would this module be necessary?). For that we have the [MenuParsers][4]. We try with our best | ||
effort to parse the menus, however there is some difficulty as restaurants won't always report items in the same way. | ||
|
||
A future point of improvement is being able to parse menus without such a brittle and forced solution. | ||
|
||
## Saving to Postgres | ||
|
||
Every item obtained from USP is piped into a PostgresQL item. This enables us to respond to clients even when USP's servers are down (which happen quite often). | ||
Every item obtained from USP is piped into a PostgresQL item. This enables us to respond to clients even when USP's | ||
servers are down (which happen quite often). | ||
|
||
## Cache | ||
|
||
When an item is successfully obtained, it's first persisted on the Postgres table (see above), and then kept in an in-memory cache. This cache allow us to quickly respond users while keeping costs down. | ||
When an item is successfully obtained, it's first persisted on the Postgres table (see above), and then kept in an | ||
in-memory cache. This cache allow us to quickly respond users while keeping costs down. | ||
|
||
It's a good idea to use a cache here, as the data that clients want is usually the menus for the current week, making cache hits very likely. | ||
It's a good idea to use a cache here, as the data that clients want is usually the menus for the current week, making | ||
cache hits very likely. | ||
|
||
## Restaurant Job | ||
|
||
In order to have all records available - even for restaurants that aren't accessed regularly - we continuously try to get all restaurants from USP, using a fixed rate schedule in [RestaurantJob class][5]. | ||
In order to have all records available - even for restaurants that aren't accessed regularly - we continuously try to | ||
get all restaurants from USP, using a fixed rate schedule in [RestaurantJob class][5]. | ||
|
||
This will both refresh our current cache and save any new menus to our persistent storage. | ||
|
||
|
||
|
||
[1]: https://github.com/JopiterApp/USP-Restaurant-API | ||
|
||
[3]: src/main/kotlin/repository/usp/USPRestaurantItemRepository.kt | ||
|
||
[4]: src/main/kotlin/repository/usp/MenuParser.kt | ||
|
||
[5]: src/main/kotlin/RestaurantJob.kt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
restaurants/src/main/kotlin/app/jopiter/restaurants/model/ClassifiedRestaurantItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.