wncc / Hello-FOSS-Chat

The Chat Application repository for Hello-FOSS
http://hello-foss-chat.herokuapp.com/
3 stars 8 forks source link

Local storage for conversations #9

Open abhipaiangle opened 3 years ago

abhipaiangle commented 3 years ago

Description

Present version stores the conversations in the python application which gets deleted when the application is refreshed.

Proposed Solution

Local storage has to be used and conversations are to be stored in browser cookies so that they are preserved for the particular user involved in the conversation.

Alternatives Considered

In case the mentioned solution is not possible, the alternative can be storage of conversations in PostgreSQL database with a specific limit to account for database expense.

sauntheninja2 commented 3 years ago

I would like to work in this and long term woudn't it be more beneficial to store the conversations in a database as opposed cookies

abhipaiangle commented 3 years ago

That was actually an alternative since it would need extra database storage. I think we can go for it. Since there is a number of messages limit to every conversation, it won't be a problem. Only hoping that PostgreSQL database would be sufficient for this.

sauntheninja2 commented 3 years ago

So how should the data be stored? The name the message and the message id right?

abhipaiangle commented 3 years ago

Display name, channel name, message, time would be sufficient I guess.

sauntheninja2 commented 3 years ago

The best way to do it would be do convert the dictionary into objects and then store them in the database right?

abhipaiangle commented 3 years ago

@sauntheninja2 Yeah. For PostgreSQL databasing, check this code . Follow the raw DB commands like the ones used in the code since the database will be similar. If you want to do it with psql ORM, let me know.

sauntheninja2 commented 3 years ago

psql ORM I feel will scale better and be easier to read

abhipaiangle commented 3 years ago

Ok. Proceed then. Make a different .py file for the objects

abhipaiangle commented 3 years ago

@sauntheninja2 Hey I have added Postgres Database to the app. You can access the database using os.getenv('DATABASE_URL') . On local system you have to set Environment variable DATABASE_URL to

postgres://hbadpcocmlhrpv:0479faf1070d0a31a66f179aaab53aec23bf9a4aa3e5c7e09e52126cc5847d32@ec2-54-146-142-58.compute-1.amazonaws.com:5432/d47ndu81md817c

sauntheninja2 commented 3 years ago

Yes i wondering whether i have to create the database or not thanks

abhipaiangle commented 3 years ago

Last 5 days remaining for hacktoberfest to end although there is no deadline for you to send in PRs. Make your contribution ASAP if the issue is fixed @sauntheninja2