I am building an app that has to do with the Powerball lottery. Basically, I have created a couple of data types.
One is “Drawing” where I create and store Drawing records that pertain to actual Powerball drawings.
I create a drawing by giving it a “date” and a “jackpot” amount.
The drawing record also has a “winning_numbers” field that set to a text list type and also a “winning_powerball” field that is set to a text type.
I also have a data type for “Tickets” that pertain to the actual lottery tickets that I purchase and enter into the system. Each Ticket has a “serial_number”, a “drawing” that should correspond to a drawing record that I created previously, some “numbers” which is a text list, a “powerball_number” which is a text field and a user or users.
Powerball results are published to a JSON file located here http://data.ny.gov/resource/d6yy-54nr.json
I would like to update the results of each Drawing that I create with the results published in the JSON file. Ideally this would happen automatically but then again I’m not sure since I cannot guarantee the availability of this data from this endpoint so maybe it would be better to just have a form for entering the winning numbers and winning powerball result but if the data is present from the json endpoint that matches the drawing record date, then prepopulate the form with that data. I already have the API setup and I am receiving the JSON just fine.
Then, once I submit the winning numbers and winning powerball results into the drawing record, I would like to find all the tickets that related to that drawing and determine if any of them are winners. I have ZERO clue as to how I would go about doing this. I tried “doing a search” for tickets where drawing = ( in here I want to match the drawing by drawing date) but I could not figure out how to do it.
Once, I am able to find the winning tickets from each drawing, I want to create a notification and send an email letting me know that I have a winner, how many matching picks I have and which ones they were.