compdemocracy / polis

:milky_way: Open Source AI for large scale open ended feedback
https://pol.is
GNU Affero General Public License v3.0
753 stars 173 forks source link

Fix possible bug in add-xid-whitelist logic #1785

Closed ballPointPenguin closed 5 months ago

ballPointPenguin commented 5 months ago

I'm still (after all these years) a relative clojure n00b, BUT it seems to me that this logic discards the first batch of xids when upserting the whitelist. e.g. If I give it a list of 200 xids, only 51-200 will be upserted and the first 50 discarded.

Does this make sense?

metasoarous commented 5 months ago

Good catch! I think it's actually dropping the final batch of comments, not the first. But yes, this is a bug.

I'd recommend sticking with the partial implementation, as it's a bit more clojuric in this case. But not a big deal either way.

metasoarous commented 5 months ago

Actually, I think what we really want is (when (seq xids-batch) ...), since I'm not sure that we want to execute an upsert if the batch is empty for some reason. I don't know off the top of my head if that would result in a pg error, but maybe better on the safe side.

ballPointPenguin commented 5 months ago

Confirmed that the original bug is dropping the final batch of XIDs, and that this change fixes that bug.