user3726445
user3726445

Reputation: 3

Visual data from logs

I have an app I'm working on that is a credits system for a store. A customer brings in items and receives a credit and then can turn around and use that credit towards certain goods in the store. I've set it up so every time a credit holder or credit is created,updated, or destroyed the event is logged. I'm wondering if there is an easy way to use the event data from the logs to create a dashboard displaying things such as X number of credits created and Y number of credits used today. This may not be the right way to go about doing this at all and if so feel free to guide me in another direction. Thanks in advance!

Upvotes: 0

Views: 48

Answers (1)

aaron-coding
aaron-coding

Reputation: 2621

You should save the information into a database (in addition) to the log and operate on it in this fashion.

So for example, maybe you have a User it should be a Model and have credits which should be an integer. You can modify this value every time a transaction happens.

You can also create an associated model 'transactions' which belong_to the user and to find out transactions that happened on a certain day, you would be able to pull up all of the transactions of that user in a certain time range.

If your credits work similar to dollars and money. And your transactions are like orders, you may want to look into using the Spree gem. https://github.com/spree/spree

You definitely do not want to be reading from the logs to do very usual actions like you're describing.

Upvotes: 1

Related Questions