|
28 | 28 |
|
29 | 29 | import click |
30 | 30 | from api import parallel_fetch, ISSUES, DEFAULT_MAX_ERRORS |
| 31 | +from viz import load_event, plot_performance, plot_version_stream |
31 | 32 |
|
32 | 33 | DEFAULT_DAYS_WINDOW = 90 |
33 | 34 | DEFAULT_CHUNK_DAYS = 1 |
@@ -149,6 +150,23 @@ def get(event, start_date, end_date, days, chunk_days, jobs, max_errors, cached_ |
149 | 150 | click.echo(f"{datetime.now(timezone.utc):%Y-%m-%d %H:%M:%S} [Finished]") |
150 | 151 |
|
151 | 152 |
|
| 153 | +@cli.command() |
| 154 | +@click.option("-o", "--output-dir", type=click.Path(file_okay=False, dir_okay=True, writable=True), default=".") |
| 155 | +@click.option("--drop-cutoff", default=None, help="Ignore versions older than this") |
| 156 | +def plot(output_dir, drop_cutoff): |
| 157 | + """Generate plots using records stored in MongoDB.""" |
| 158 | + today = datetime.now().date().strftime("%Y%m%d") |
| 159 | + out_perf = os.path.join(output_dir, f"{today}_weekly.png") |
| 160 | + out_ver = os.path.join(output_dir, f"{today}_versionstream.png") |
| 161 | + |
| 162 | + unique_started = load_event("started") |
| 163 | + unique_success = load_event("success") |
| 164 | + |
| 165 | + plot_performance(unique_started, unique_success, drop_cutoff=drop_cutoff, out_file=out_perf) |
| 166 | + plot_version_stream(unique_started, unique_success, drop_cutoff=drop_cutoff, out_file=out_ver) |
| 167 | + click.echo(f"Saved plots to {output_dir}") |
| 168 | + |
| 169 | + |
152 | 170 | if __name__ == "__main__": |
153 | 171 | """ Install entry-point """ |
154 | 172 | cli() |
0 commit comments