Don't know if you live near the beach or up north where they salt the road in the winter but in either case you need to regularly wash and coat bare medals and always lubricate when storing. In the future there is something else you can do after WD40'ing, take chain over something hard and round and tap LIGHTLY with hammer so it forces it to bend thus breaking the rust loose, repeat lube, put chain back on bike, turn upside down and spin pedals.
There was a time when I was but a wee lil wal that I so loved repairing bikes. I would take different bikes and combine pieces and make all kinds of creations. Add extra forks to make chopper styles, the works. I thought I would grow up and be the worlds best bike repairer. I didn't.