The image and the story can apply to several at the same time. This is why numbers often repeat themselves throughout the Bible. 40 days and nights Moses spent on the mountain. 40 years Israel spent in the desert. 40 days and nights Jesus spent in the desert. 40 days Jesus spent on Earth after the resurrection before he ascended to Heaven. In three days the Cupbearer would be restored after being imprisoned, three days Jonah spent in the beast before being returned to the world, Jesus rising on the third day.
Mary is the New Eve. She is also the mother of the church. Her children are persecuted by Satan much like Eve’s children were. So yes, in some respects the imagery of Revelation 12 is of the Church, but it is also of Mary herself. We don’t know why the number 3 1/2 is chosen, other than it is half of 7, which signifies a mid point. 7 is associated with perfection and completion.