"""Get feature flags.""" from flask import request from pythonfeatures import pythonfeatures from pythonfeatures.constants import split as split_constants from sound_recordings import config from sound_recordings.constants import feature_flag def is_generate_optimized_size_fields_enabled(identity_id): # noqa D103 if identity_id is None: return False message = ( pythonfeatures.get_single_feature_by_attributes( feature_flag.GENERATE_OPTIMIZED_SIZE_FIELDS, {'service': config.SERVICE_NAME, 'identity_id': identity_id} ) ).message return message == split_constants.FEATURE_ENABLED def is_has_fingerprint_rule_in_snowflake_enabled(): """Whether fingerprint-rule reads/writes should use Snowflake (else Neo4j).""" identity_id = request.headers.get('Orchard-Identity-Id') if identity_id is None: return True message = ( pythonfeatures.get_single_feature_by_attributes( feature_flag.HAS_FINGERPRINT_RULE_IN_SNOWFLAKE, {'service': config.SERVICE_NAME, 'identity_id': identity_id} ) ).message return message == split_constants.FEATURE_ENABLED