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

@@ -67,6 +67,6 @@ import qldbtools as ql
./bin/mc-db-view-info < db-info-2.csv
./bin/mc-db-unique < db-info-2.csv > db-info-3.csv

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:

View File

@@ -0,0 +1,16 @@
# Experimental work with utils.py, to be merged into it.
from utils import *
from pprint import pprint
#* Reload gzipped CSV file to continue work
df2 = pd.read_csv('db-info-2.csv')
df_sorted = df2.sort_values(by=['owner', 'name', 'creationTime'])
df_unique = df_sorted.groupby(['owner', 'name']).first().reset_index()
#
# Local Variables:
# python-shell-virtualenv-root: "~/work-gh/mrva/mrvacommander/client/qldbtools/venv/"
# End:
#