Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Mann reservable lcd #73

Merged
merged 39 commits into from
Sep 14, 2018
Merged

Mann reservable lcd #73

merged 39 commits into from
Sep 14, 2018

Conversation

cappadona
Copy link
Contributor

@cappadona cappadona commented Sep 14, 2018

Digital signage showing availability for 3 study rooms on the 2nd floor of Mann that transitioned from loanable to reservable for the start of the Fall 2018 semester.

  • Mann 270 (small group)
  • Mann 271 (indiv)
  • Mann 272 (indiv)

Generic implementation allowing for additional spaces-related signs by updating utils/libcal-schema.js and then following the [location]/spaces/[category] route pattern.

cappadona and others added 30 commits March 23, 2018 00:17
Using two tiers of mocked data:

* first result set is hardcoded into a mocked components

* second result set is loading a mocked JSON file based on actual LibCal
  API response

Very much a work in progress.
First pass at this. Not accounting for leading available slots since
we're still working with mock data and unsure whether the API
drops/excludes bookings once current time is greater than the `toDate`.

Early testing indicates this is not the case (any booking with a
datetime for the requested date remains), which will mean more logic
needs to be introduced to handle open and current availability.
Leaning heavily on lodash chaining [1] to filter and map the original
bookings array returned by LibCal API. Big hat tip to Pete from this SO
thread [2].

[1] https://blog.mariusschulz.com/2015/05/14/implicit-function-chains-in-lodash
[2] https://codereview.stackexchange.com/questions/82596/lodash-chain-implementation
While implementing this, realized that the filter for removing past
bookings needs to be moved to the end of the chain, after the logic for
determining availability padding.
Can't hurt to double check. Don't assume that LibCal spaces API returns
bookings that abide to current/correct hours.
* Ensure moment object is returned

* Split out check for early morning closing (DRY)

* Dedicated function to format time for display
Served admirably...
Mocked data is no longer needed, so drop it along with baggage. Only
fetching data via LibCal API on initial load for now (no interval).

TODO: Use dotenv to handle sensitive LibCal oAuth data
Allow for more flexibility to better accommodate future use cases with
minimal effort.

* Move _location (aka library) to first segment

* Pass category as route param for spaces

> For now, moving Mann signs (consultation desks and study rooms) but
> leaving OKU untouched to avoid downtime. TODO: coordinate new URLs
> with Olin & Uris circ at later date.
First step in cleaning house and modularizing LibCal utils. Potential to
eventually extract into separate package.

Also generalize the hours related functions to use `location` in place
of 'desk'. Still a bit awkward with passing of the `isDesk` param to
handle different lookup in the schema, but wanted to keep the
consultation desks grouped together. Most likely will revisit this down
the road.
No longer hardcoded for Mann study rooms.
Necessary since LibCal returns empty array if no bookings exist.
Still a bit of a work in progress in terms of:

* logic for space open/close

* assumption that all requested spaces follow same hours
  (applicable for the Mann reservable study room pilot)
Still a work in progress. Need to fine tune the filtering (down to
requested spaces). Also started on simplifying opening/closing via hours
store, but needs work.
All together now...

* dotenv [1]
* axios module [2]
* proxy module [3]
* serverMiddleware [4]
* body-parser [5]

Go team.

Heavily based on modify-post example [6] from http-proxy-middleware. The
need to restream the parsed body prior to proxying [7 - 9] was a special
treat.

[1] https://github.com/motdotla/dotenv
[2] https://axios.nuxtjs.org/
[3] https://github.com/nuxt-community/proxy-module
[4] https://nuxtjs.org/api/configuration-servermiddleware
[5] https://github.com/expressjs/body-parser
[6] https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/modify-post.md
[7] chimurai/http-proxy-middleware#40 (comment)
[8] http-party/node-http-proxy#1027
[9] http-party/node-http-proxy#1264
Quick refactor in attempt to maintain overall clarity for Nuxt config.
Rename existing `formatFutureOpening()` used for consultation signs to
`formatStatusChange()`.
No longer needed now since CORS is a non issue thanks to proxying
implemented in cc90db6. All axios all the time.

> jsonp-promise first introduced via 41
* time every 10s
* hours every 30s
* reservations every 1m
Doh...cherry-picking on the import was not intended here.

Was causing trouble when fetching reservations from the client via
setInterval. Specifically when attempting to build the schedule using,
encountering `undefined` errors for the lodash methods.
Quick-n-dirty for now with Font Awesome 5.2 via CDN.

WIll revisit to:

* Use packages & official Vue.js components

* Clean up logic for determining which icon applies for each space
Doh. Never encountered this with the consultation desks but today with
the Fall semester in full swing, moment's isBetween() was always
returning false for reservable study spaces.

Probably should consider refactoring the closingTime() method to pass
hours as optional argument instead of always fetching them from the
LibCal API. This would allow further DRYing.
Go time...will be revisited.
As per feedback from working group. Chromebox is having difficulty
rendering lightweight Lato. Keeping it for meridiem on block start time
since it appears to be legible on the photos sent by the group.
Default is 20. Noticed that a reservation for 270 was dropped from the
sign during the day. While bumping to the max provides us some leeway,
we will have to keep our eye on this and see if we still hit the ceiling
during peak semester activity.
And more breathing room for header. Go team!
Not sure if something changed in LibCal's API response, but this hadn't
been necessary until noticing the issue today.
Via unique-string package.
There are occasions when the object exists but the schedule array is
empty due to the fact that the API returns all bookings (even canceled
by either party) and only those bookings with a `confirmed` status
remain after filtering.
@cappadona cappadona self-assigned this Sep 14, 2018
@cappadona cappadona merged commit 771f109 into master Sep 14, 2018
@cappadona cappadona deleted the mann-reservable-lcd branch September 14, 2018 18:00
cappadona added a commit that referenced this pull request Sep 21, 2018
Doh! Originally introduced in 1da732a as part #73.
cappadona added a commit that referenced this pull request Sep 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant