bsogata / course_availability

Tracks the availability of courses at the University of Hawaii at Manoa.
http://obscure-mesa-6109.herokuapp.com/
0 stars 0 forks source link

Email to user #13

Open HC008 opened 11 years ago

HC008 commented 11 years ago

Create a behind the scenes action to have the server email notification to user when the class available or not available.

HC008 commented 10 years ago

Email feature works for now by sending a welcome email to the a user who just created their account. This will be retained as well as with the addition of sending out emails to users based on their frequency to notify about the classes being added for tracking.

Also, in environment.rb, where the information for smtp settings are was modified to used environment variables for our website's email username and password. By doing this it would protect the information of the account since it would be on Github. The variables and the respective values are in application.yml

Changed the from part from the email address to UH Course.

HC008 commented 10 years ago

A suggestion about the type of frequency to sent out can be broken down to 2 cases in the coding part. The suggestion was to leave the selection view just as it is that offers daily, min, and hrs for the user to select. In the actual coding it would just only be daily and min.

For example, if the user enters 2 hrs then it would be converted to minutes in the code and sent out the emails based on minutes that adds up to the hrs instead of having to convert etc. This way reduces redundancy and makes it a little easier to manage the code. Also, for the daily part I think we can set it to just sent out at 12 a.m. instead of having to keep track of when the user set it and then 24 hours from that setting. It would be no matter what time the user sets it it would be sent out at the next time when it is 12 a.m.

bsogata commented 10 years ago

The notification emails never appear to be sent out; it is unclear when the self.perform method in users_helper.rb is called. One possibility is to call the method when the user saves his or her settings, and assuming that "every" works as this developer expects (that is, that it continues running the code without stopping the rest of the application from continuing on) this will keep checking the course availability site every x units of time.

This process should only send the email out when the user first tracks a course or when the number of seats changes between zero and non-zero. Users will not respond well to receiving emails every five minutes saying that the number of seats open has not changed. If the user receives an email when first tracking a course though, that will let the user know that the tracking is set up and how the message system will work. Similarly, the user really only cares if seats become available (zero to non-zero) or not available (non-zero to zero).

This means that for each user, when the frequency indicates that it is time to check the Course Availability site, the following should occur (hopefully using better written Ruby code than this):

For each course c that the user is tracking
  Check the current seats available for the course
  If c.seats == 0 and current_seats != 0
    Send email indicating that seats are now available
  Else if c.seats != 0 and current_seats == 0
    Send email indicating that seats are no longer available
  end
  If c.seats != current_seats, update c.seats
end