The relation between puppet classes and lookup keys are a bit complicated.
There are two types of relation 
1. Smart variable - Lookup keys that are attached to a class and will be sent to the host in the ENC as global parameters if the class is attached to a host.
2. A class parameter - Lookup key that is attached to a class in a specific environment, we discover the class parameters in the import process, if foreman admin select to override the default value, foreman sends the value as a class parameter in the ENC.

It need special sql counter that aggregate both relations, or two counters.