def get_active_by_product(product): """ Returns all active tests by product name """ results = [] experiences = get_experiences() if product == 'dsco': for exp in experiences: experience_name = exp["experience_name"] if any(word in experience_name.lower() for word in DSCO_KEYWORDS): results.append( create_external_link(experience_name, exp["id"]) + " " + experience_name) else: product_search_string = "[" + product for exp in experiences: experience_name = exp["experience_name"] if product_search_string in experience_name.lower(): results.append( create_external_link(experience_name, exp["id"]) + " " + experience_name) if not results: return NO_RESULTS_FOUND return "\n".join(results)
def get_by_recent_days(days): """ Return all active tests launched in the past xx days """ if not days.isdigit(): return INVALID_DAY_ENTERED days = int(days) if days > 120: return MAX_DAYS experiences = get_experiences() days_offset = datetime.today() - timedelta(days=days) results = [] for exp in experiences: launch_date = datetime.strptime(exp["start_time"], "%Y-%m-%dT%H:%M:%S.%fZ") experience_name = exp["experience_name"] if launch_date > days_offset: results.append( create_external_link(experience_name, exp["id"]) + " " + experience_name) if not results: return NO_RESULTS_FOUND return "\n".join(results)
def get_active_ab_tests(): """ Grab all active A/B tests """ results = [] experiences = get_experiences() for exp in experiences: exp_name = exp["experience_name"] external_link = create_external_link(exp_name, exp["id"]) results.append(f"{external_link} {exp_name}") if not results: return NO_RESULTS_FOUND return "\n".join(results)
def get_active_psupport(): """ Returns all active prod support tests """ results = [] experiences = get_experiences() for exp in experiences: if len(exp["splits"]) == 1: exp_name = exp["experience_name"] external_link = create_external_link(exp_name, exp["id"]) results.append(f"{external_link} {exp_name}") if not results: return NO_RESULTS_FOUND return "\n".join(results)
def get_active_by_EFEAT(efeat_num): """ Return the details of a ticket by EFEAT#### """ if len(efeat_num) != 4: return INVALID_EFEAT_ENTERED efeat_dict = {} experiences = get_experiences() found = False for exp in experiences: experience_name = exp["experience_name"] if efeat_num in experience_name: found = True efeat_dict["Test Name"] = experience_name efeat_dict["Launch Date"] = format_date(exp["start_time"]) efeat_dict["Link"] = create_external_link(experience_name, exp["id"]) if found: return json.dumps(efeat_dict, indent=0)[2:-2] return NO_RESULTS_FOUND