I have a user who has joined a challenge ( He needs to cover 150000 steps a month and 5k steps daily). So now I track his daily activity. Suppose after 7 days I find that he should have covered 35k steps but has covered only 25k steps then I need to tell him that his average is 25k/7 and he needs to do 35k/7 - 25k/7 steps extra everyday to meet his daily goals.
I have a UserActivity class which keeps a track of the user’s activity like his daily steps, his monthly goal, progress, start date, end date etc.
Now I have to design an algorithm to motivate users based on their performance. So I need to motivate a lazy person in a different way than a person who does not need any motivation from me.
My question is that where should I keep this algorithm, will this be in the UserActivity model? Or should I create a service class?
My approach is that if it is in fact a service, i.e. you tell it to do something and are not particularly interested in it’s data, you can put it on an app/services directory. If not, you can create a class and put in either the app/models or lib directories.
Remember, a class does not need to inherit from ActiveRecord in order to belong to the models directory.
Thanks. This is the first full web application I am developing. So there is no way I can predict the problems before hand. Plus I have been given a target to release a prototype by 24th feb including the UI.