Add mc-db-unique as default single-(owner,repo) selector

This commit is contained in:
Michael Hohn
2024-07-26 14:18:14 -07:00
committed by =Michael Hohn
parent 92ca709458
commit 81c44ab14a
3 changed files with 60 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
#!/usr/bin/env python
""" Read a table of CodeQL DB information,
group entries by (owner,name), sort each group by
creationTime and keep only the top (newest) element.
"""
import argparse
import logging
#
#* Configure logger
#
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
# Overwrite log level set by minio
root_logger = logging.getLogger()
root_logger.setLevel(logging.INFO)
#
#* Process command line
#
parser = argparse.ArgumentParser(
description=""" Read a table of CodeQL DB information,
group entries by (owner,name), sort each group by
creationTime and keep only the top (newest) element.
""")
args = parser.parse_args()
#
#* Collect the information and select subset
#
import pandas as pd
import sys
df0 = pd.read_csv(sys.stdin)
df_sorted = df0.sort_values(by=['owner', 'name', 'creationTime'])
df_unique = df_sorted.groupby(['owner', 'name']).first().reset_index()
df_unique.to_csv(sys.stdout, index=False)
# Local Variables:
# python-shell-virtualenv-root: "~/work-gh/mrva/mrvacommander/client/qldbtools/venv/"
# End: