Smashing / smashing

The exceptionally handsome dashboard framework in Ruby and Coffeescript.
https://smashing.github.io/
MIT License
3.22k stars 324 forks source link

Using sqlite to save history #194

Closed rreilly-edr closed 2 years ago

rreilly-edr commented 2 years ago

Can someone point to a more in depth example of how to use sqlite to save history ? I am not understanding the example on the wiki. Thanks

kinow commented 2 years ago

Hi @rreilly-edr ,

For questions like this one, it's better to use the Gitter chat https://gitter.im/Smashing linked in the README.md and CONTRIBUTING.md files.

kinow commented 2 years ago

I believe this is the Wiki page you were looking at: https://github.com/Smashing/smashing/wiki/How-To:-Define-a-data-model-and-store-history-data-to-database

I haven't done that yet, but what I understood after read that, is that you'd need to define a Ruby file in your lib directory, inside your dashboard project folder. That would use data_mapper or any other gem that you prefer to interface with sqlite (or another DB).

The final paragraph describes how you would then use this file from the lib directory inside your job. The job would require that library file, and use the code to persist the event in the sqlite DB.

YourDataModel.new({:createdAt => DateTime.now, :serviceName => 'service1', :available => succeed}).save()
puts "YourDataModel.all().count #{YourDataModel.all().count}"

Instead of puts and writing it to the default output, you would probably send some data to be displayed in a widget instead, I guess.

Hope that helps, -Bruno