ineshbose / boyd_bot_messenger

Boyd Bot (Flask Version)
https://inesh.xyz/boyd_bot_messenger
MIT License
6 stars 3 forks source link

One Time Use Support #8

Closed ineshbose closed 4 years ago

ineshbose commented 4 years ago

Enable users to use the bot and not have their University ID & Password stored in the database, but to fetch the calendar once.

This will require a BooleanField in RegisterForm with label "Remember me" (default=True) and just store their sender ID in the database for getting to the gateway.

However, this feature may be unstable since the once-fetched calendar may get lost (a small chance).

ineshbose commented 4 years ago

Dictionary calendar is very very inconsistent causing loss of calendar mid-use. Unable to re-login, the calendar can't be fetched.

ineshbose commented 4 years ago

Problem found: os.getpid() gives different output on Heroku which means that processes are switching and so data is lost between the processes.

Possible solutions:

  1. Database: Destroys the point of the app since timetable changes are supposed to be live. Maybe expire data, but fetching/inputting would be some work. Not desirable.
  2. multiprocessing: Not supported by Gunicorn workers. In this case, again, probably not desirable either.
  3. pipes?
ineshbose commented 4 years ago

Two solutions:

  1. Procfile: add a --workers 1 between web: gunicorn and run:app. This method, however, won't be great for large-scale use.
  2. redis/caching: Implement a redis database ONLY in timetable.py that clears and sets in __init__() everytime.

Refer: https://stackoverflow.com/questions/62328835/why-my-flask-backend-is-unstable-on-heroku

ineshbose commented 4 years ago

ISSUE DEBRIEF:

Since this feature can be disabled, it's the developer's choice and responsibility to use it in the best way possible. Therefore, either they disable the feature, or ensure that the app uses one process/worker when deployed.

For now, the issue is closed.