codecov/worker

Mismatched counts of activated users

drazisil-codecov opened this issue · 0 comments

def get_installation_plan_activated_users(db_session) -> list:
query_string = text(
"""
WITH all_plan_activated_users AS (
SELECT
UNNEST(o.plan_activated_users) AS activated_owner_id
FROM owners o
) SELECT count(*) as count
FROM all_plan_activated_users"""
)
return db_session.execute(query_string).fetchall()

This query returns duplicate values, since there is no DISTINCT clause. As a result, we can count the license as being over the seat count and disable notifications, while still showing the customer that they are below the user count on the UI header, which pulls from here

https://github.com/codecov/codecov-api/blob/11e2a1ea42bd71ef9446bbe8b85d7513733e0171/services/self_hosted.py#L52-L68

These two queries should return the same count.