Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dining redesign: open until subtitle, updated day chips, availability card redesign, improved chart and menus #48

Merged
merged 33 commits into from
Aug 15, 2020

Conversation

kaushikravikumar
Copy link
Contributor

@kaushikravikumar kaushikravikumar commented Jun 14, 2020

Summary

This pull request adds a toolbar that utilizes the api endpoint facilityHours in order to fetch the operating hours of a facility. Using this info, the user sees in the subtitle of the toolbar whether it's open or closed and exactly when it is open until or when it is closed until. Right Now, entire subtitle is red or green depending on whether it is closed or open. Will work on implementing it such that it matches the design on Figma, where only the word open or closed is colored in.

This pull request is the first step towards the dining redesign effort.

  • Changed Day Chips Design
  • Toolbar with Open/Close Info for facility
  • Change Availability Card
  • Clean up Menu design
  • Gray out closed hours of Historical data chart

Test Plan

  • I created a list inside the facilityHoursOnResponse function definition inside of the checkFacilityIsOpen() function inside the FacilityInfoPage Kotlin activity. This list had a bunch of sample unix timestamps for a day's operating hour time slots. The last element was the first time slot of the next day. This hardcoded list allows us to test our onResponse handler, since right now any request to the operatingHours endpoint will return an empty list. Then, we should also hardcode the currentTime variable within this function and play around with its value ensuring the results are as expected.

  • The cases we must test are as follows. The case that the currentTime is lower than the first time slots open time. Next case, is that the currentTime falls into one of the time slots in the day meaning that the facility is open. Another case is that the currentTime falls between two time slots so the facility is closed and will open when it is the second of the two time slots' open time. Finally, the last case is that the time is past the last time slot of the day's close time. After ensuring that all these edge cases are met, we should be good to go.

  • We must also make sure to test that the JSON parsing of the API response works as expected! In order to do this, we should actually mock the API response, so that we are testing the JSON parsing of the API response body.

Screenshot_20200614-003344

Updated screenshot (2020-06-27)
Screenshot_Flux_20200627-185603

Notes

In building this feature, I had to make a few minor changes in other parts of the code.

  1. Moved parseTime function from jsonParser class to FluxUtil, since it made more sense being a util function for the entire project, plus I ended up using the function in FacilityInfoPage.
  2. Edited getCurrentDate() and getDayStringDaysAfter() functions in FluxUtil to ask for param specifying what format we want the date returned in, with year first or last (MM-DD-YYYY or YYYY-MM-DD). However this is something we should standardize across all our backend api endpoints. Thus, this is jus a temporary change!

@kaushikravikumar kaushikravikumar requested a review from a team as a code owner June 14, 2020 07:35
@dti-github-bot
Copy link
Member

dti-github-bot commented Jun 14, 2020

[diff-counting] Significant lines: 766.

@kaushikravikumar kaushikravikumar self-assigned this Jun 14, 2020
@kaushikravikumar kaushikravikumar added the feature New feature or request label Jun 14, 2020
Copy link
Member

@kungpaogao kungpaogao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far! I'm thinking we could probably optimize how many requests we make, since we're getting the operating hours with the historical data already.

Comment on lines 176 to 188
fun facilityHours(facilityId: String, startDate: String, endDate: String, facilityHoursOnResponse: (List<Pair<Long, Long>>) -> Unit) {
val facilityHoursRequest = getRequest(
url = "$OPERATING_HOURS_ENDPOINT?id=$facilityId&startDate=$startDate&endDate=$endDate",
onResponse = { response ->
facilityHoursOnResponse(JsonParser.parseOperatingHoursToTimestampList(response))
},
onError = {
error -> Log.d("Error fetching hours", error.networkResponse.toString());
}
)
queue.add(facilityHoursRequest)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since fetchHistoricalJSON() also does a request to get the operating hours, it would make sense to combine the two in some way. Right now, I think you end up fetching it twice in FacilityInfoPage.kt.

*/
fun getCurrentDate(): String {
fun getCurrentDate(yearBeginning: Boolean): String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should get backend to update to use ISO format with year at beginning LOL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, there's another function called getDate() that we should probably combine

fun parseTime(timestamp: Long): String {
val timeZone = Calendar.getInstance().timeZone
var format = SimpleDateFormat("h:mma", Locale.US)
if (DateFormat.is24HourFormat(DensityApplication.getAppContext())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love me some 24h time 😍

Copy link
Member

@kungpaogao kungpaogao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the improvements to the API calls - it makes a lot of sense to pair the timestamps + interval strings together and have the view determine what to use.

Comment on lines 167 to 173
fun facilityHours(facilityId: String, startDate: String, endDate: String, facilityHoursTimeStampsOnResponse: (List<Pair<Long, Long>>) -> Unit,
facilityHoursStringsOnResponse: (List<String>) -> Unit) {
val facilityHoursRequest = getRequest(
url = "$OPERATING_HOURS_ENDPOINT?id=$facilityId&startDate=$startDate&endDate=$endDate",
onResponse = { response ->
facilityHoursOnResponse(JsonParser.parseOperatingHoursToTimestampList(response))
facilityHoursTimeStampsOnResponse(JsonParser.parseOperatingHoursToTimestampList(response))
facilityHoursStringsOnResponse(JsonParser.parseOperatingHours(response))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good, makes sense to pair these together

Comment on lines 221 to 224
facilityHoursStringsOnResponse = {
hoursStringsList ->
opHoursStrings = hoursStringsList
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will things get messed up if opHoursStrings is not set in time for the UI updates?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it won't throw an error since it's just an empty list...

Comment on lines 35 to 38
/**
* getDate(day) provides the date for historical endpoint request.
* getDateString(day) provides the date in string format for historical endpoint request.
*/
fun getDate(day: String): String {
fun getDateObject(day: String): Date {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did the documentation get mixed up?

kungpaogao and others added 10 commits July 5, 2020 14:37
- left-align chips
- move chips out of card
- update font color/styles
- remove accessibility icon when closed
- change FluxUtil.convertDateObjectToString to use ISO format (yyyy-MM-dd)
- now works with new backend changes
- made the bars only rounded on the top
- updated label and axis colors
- updated some code style
- TODO: improve performance
@kungpaogao kungpaogao self-assigned this Jul 11, 2020
Copy link
Member

@kungpaogao kungpaogao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably get another pair of eyes on this, but I think it's ready to merge.

@kungpaogao kungpaogao requested a review from SamChou19815 August 7, 2020 05:08
@kungpaogao
Copy link
Member

Merging for now, but there is still a related issue #49.

@kungpaogao kungpaogao changed the title Dining redesign: Toolbar includes open/close info of facility Dining redesign: open until subtitle, updated day chips, availability card redesign, improved chart and menus Aug 15, 2020
@kungpaogao kungpaogao merged commit 5c179ba into master Aug 15, 2020
@kungpaogao kungpaogao deleted the dining_redesign branch August 15, 2020 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants