Merging from `db_access.py` `get_unique` and `get_unique_count`?
Both functions are extremely similar, would it be possible to merge them in a sane way?
I haven't come up with a good idea yet. I thought of the following options:
- Having one of the functions call the other.
Clearly, this could only work one way: get_unique_counts calls get_uniques. Yet, get_unique_counts should also work with very large numbers. This works as of now, since the computation happens within database. If one was to first retrieve all unique values and then count oneself, this could lead to very large resource usage.
- Externalizing the common denominator.
Afaict, the common denominator is 1-2 loc.
- Making one function out of the two and using a parameter indicating the desired return value/type.
I'm not so sure about how intuitive/user-friendly this is.
What did you have in mind?
Option 3 is what I was thinking about. An argument telling that in one case you have to use an aggregation function and in the other, no function is used. Is there anything like a no-op function that could help in keeping the code simple?
I wouldn't be too concerned about it being intuitive, in the end, the user never sees these functions but a higher-level interface.