@@ -0,0 +1,2526 @@
+from optparse import OptionParser%0Afrom queue import LifoQueue%0Afrom typing import Iterator, List%0A%0Aimport requests%0Afrom logger import logger%0A%0ABASE_URL = 'http://showfast.sc.couchbase.com'%0A%0A%0Adef get_menu() -%3E dict:%0A    return requests.get(url=BASE_URL + '/static/menu.json').json()%0A%0A%0Adef get_benchmarks(component: str, category: str) -%3E List%5Bdict%5D:%0A    api = '/api/v1/benchmarks/%7B%7D/%7B%7D'.format(component, category)%0A    return requests.get(url=BASE_URL + api).json() or %5B%5D%0A%0A%0Adef hide_benchmark(benchmark_id: str):%0A    api = '/api/v1/benchmarks/%7B%7D'.format(benchmark_id)%0A    requests.patch(url=BASE_URL + api)%0A%0A%0Adef showfast_iterator(components: List%5Bstr%5D) -%3E Iterator:%0A    for component, meta in get_menu()%5B'components'%5D.items():%0A        if component in components:%0A            for category in meta%5B'categories'%5D:%0A                yield component, category%5B'id'%5D%0A%0A%0Adef parse_release(build: str) -%3E str:%0A    return build.split('-')%5B0%5D%0A%0A%0Adef benchmark_iterator(components: List%5Bstr%5D, max_builds: int) -%3E Iterator:%0A    for component, category in showfast_iterator(components=components):%0A        curr_metric, curr_release = None, None%0A        queue = LifoQueue(maxsize=max_builds)%0A%0A        for benchmark in get_benchmarks(component, category):%0A            if not benchmark%5B'hidden'%5D:%0A                release = parse_release(benchmark%5B'build'%5D)%0A%0A                if curr_metric != benchmark%5B'metric'%5D:%0A                    curr_metric, curr_release = benchmark%5B'metric'%5D, release%0A                    queue.queue.clear()%0A%0A                if release != curr_release:%0A                    curr_release = release%0A                    queue.queue.clear()%0A%0A                if queue.full():%0A                    yield benchmark%0A                else:%0A                    queue.put(benchmark)%0A%0A%0Adef hide(components: List%5Bstr%5D, max_builds: int):%0A    for b in benchmark_iterator(components=components, max_builds=max_builds):%0A        logger.info('Hiding: build=%7Bbuild%7D, metric=%7Bmetric%7D'.format(**b))%0A        hide_benchmark(b%5B'id'%5D)%0A%0A%0Adef main():%0A    parser = OptionParser()%0A%0A    parser.add_option('-c', '--components', dest='components', default=%5B%5D,%0A                      type='str', help='comma separated list of components')%0A    parser.add_option('-m', '--max-builds', dest='max_builds', default=8,%0A                      type='int', help='maximum number of builds per release')%0A%0A    options, args = parser.parse_args()%0A%0A    hide(components=options.components.split(','),%0A         max_builds=options.max_builds)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

Add a script for hiding old ShowFast results