shaunburdick / slack-ooo

Out of Office bot for Slack
Other
71 stars 28 forks source link

Save OoO Statuses in DB #1

Open shaunburdick opened 9 years ago

shaunburdick commented 9 years ago

It would be nice to save the app data so it is not lost on restart.

shaunburdick commented 8 years ago

Bumping this to the top of my list, it really needs to get done

andela-anandaa commented 8 years ago

You think SQLite can be ok or which DB would you like to use? Or Firebase? I could take on this.

shaunburdick commented 8 years ago

I would say something remote like Firebase or Mongo. SQLite doesn't work so well with Docker unless you force people to use volumes/ Take a look at what I did with the gamebot: https://github.com/cinderfish/gamebot/tree/master/lib/storage Having a driver system gives you options so you could have an SQLite driver if you wanted

andela-anandaa commented 8 years ago

Sure, the cloud-based option is better and extensible in a way that the same data could be shared by other apps, if need be. I'll go with Firebase, you did some cool stuff on the gamebot. Can I just take the same approach? I can be on it this evening after-hours.

shaunburdick commented 8 years ago

Sounds good to me!

andela-anandaa commented 8 years ago

Working on this. Do you think simply syncing the loopkup map in lib/bot.js with Firebase (in a plug-in/out configurable way) will be a good way to do this?

shaunburdick commented 8 years ago

You don't really need to sync the lookup seeing you get that on each connect. What I would do would be to add a method to the OOOUser class:

{
    id: 'foo',
    message: 'some message',
    start: 12345566788, // unix timestamp
    end: 1234556677, // unix timestamp
}

Storage could be handled by the bot, each time there is a CRUD operation on the ooo_users map it would trigger the bot to serialize that user and send it off to the database. On boot up, the bot would connect to the database and pull down all the ooo users, instantiating a new OOOUser for each one and adding it to the ooo_users map.

andela-anandaa commented 8 years ago

Sounds good!