There is no 180 days per year limit.
On an ESTA, you can stay up to 90 days per visit.
Now, there is also a less clearly defined rule that you must not use repeated or successive visits to live in the US, so you can’t go to the US for 90 days, leave the US for a few days, then go back to the US for 90 more days, rinse, and repeat.
The unofficial rule of thumb is that you should stay out of the country about as much as you stayed in. In effect, that means you indeed can’t stay more than half of the time in the US, but it’s not a hard and fast rule, it’s up to the appreciation of the CBP officer on each visit.
So there’s no calendar year, no sliding window, just make sure your successive stays in the US don’t amount to living there.
Given the time spent outside of the US between your two visits, this shouldn’t be an issue. Yes, the fact that you have long stays in the US and that you have a boyfriend in the US probably raise a few timid reddish flags, but the length between the visits and your situation in the UK are very much in your favour, so I wouldn’t worry too much.
The one issue which you may be questioned about is how you can afford to spend so much time on holiday, though. Make sure you don’t need to work, even remotely, while you are in the US.
As an aside, if you were to spend more than half of your time in the US, on top of immigration-related issues, you would have issues with taxes, as you would become a tax resident in the US. But you are quite far from that at this time.