diff --git a/code/query/Summary.py b/code/query/Summary.py index e7447fc..0fa3203 100644 --- a/code/query/Summary.py +++ b/code/query/Summary.py @@ -1,12 +1,55 @@ -from core.Constants import DataTypeKeys, DataTypeName +from core.Constants import DataTypeKeys, DataTypeName, MigrationKey, LibPairKey +from db.LibPair import LibPair +from db.Migration import Migration from query.Query import Query from query.Result import Result, ResultDisplayOption class Summary(Query): def run(self): - result = {} - for dt in DataTypeKeys: - result[DataTypeName[dt]] = len(self.db.get_list(dt)) + migs: list[Migration] = self.db.get_list(MigrationKey) + all_lib_pairs: list[LibPair] = self.db.get_list(LibPairKey) + sources = {lp.source for lp in all_lib_pairs} + targets = {lp.target for lp in all_lib_pairs} + libs = sources.union(targets) + domains = {lp.domain for lp in all_lib_pairs} + repos = {mg.repo for mg in migs} + commits = {mg.commit for mg in migs} + lib_pairs_having_migs = {mg.pair_id for mg in migs} + + migs_having_code_changes = set() + lib_pairs_having_code_changes = set() + repos_having_code_changes = set() + commits_having_code_changes = set() + + file_count = 0 + segments_count = 0 + for mg in migs: + cc_in_mig = len(mg.code_changes) + if cc_in_mig: + migs_having_code_changes.add(mg.id) + lib_pairs_having_code_changes.add(mg.pair_id) + repos_having_code_changes.add(mg.repo) + commits_having_code_changes.add(mg.commit) + file_count += cc_in_mig + segments_count += sum(len(cc["lines"]) for cc in mg.code_changes) + + result = { + "analogous library pairs": len(all_lib_pairs), + "unique libraries": len(libs), + "unique source libraries": len(sources), + "unique target libraries": len(targets), + "unique library domains": len(domains), + "migrations": len(migs), + "client repositories having migrations": len(repos), + "library pairs having migrations": len(lib_pairs_having_migs), + "migration commits": len(commits), + "migrations having code changes": len(migs_having_code_changes), + "library pairs having code changes": len(lib_pairs_having_code_changes), + "client repositories having code changes": len(repos_having_code_changes), + "commits having code changes": len(commits_having_code_changes), + "modified files": file_count, + "modified code segments": segments_count + } return Result([result], ResultDisplayOption.DATA_ONLY) diff --git a/docs/examples.md b/docs/examples.md index 6f4f817..dd531dc 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -19,8 +19,21 @@ python pymigbench.py **Result:** ```yaml -- library pair: 59 - migration: 157 +- analogous library pairs: 59 + unique libraries: 99 + unique source libraries: 55 + unique target libraries: 56 + unique library domains: 13 + migrations: 157 + client repositories having migrations: 127 + library pairs having migrations: 49 + migration commits: 155 + migrations having code changes: 75 + library pairs having code changes: 34 + client repositories having code changes: 57 + commits having code changes: 74 + modified files: 161 + modified code segments: 375 ``` ## Get count of _lib pairs_ in `File reader/writer` domain **Command:** diff --git a/docs/run_site.bat b/docs/run_site.bat new file mode 100644 index 0000000..4a5105c --- /dev/null +++ b/docs/run_site.bat @@ -0,0 +1 @@ +bundle exec jekyll serve \ No newline at end of file diff --git a/docs/tool.md b/docs/tool.md index 304458e..8bbd1b6 100644 --- a/docs/tool.md +++ b/docs/tool.md @@ -14,10 +14,23 @@ and extract it. This is the folder where you will find a `requirements.txt` file. 4. Install the dependencies. Run `pip install -r requirements.txt` -If there is no error, run `python pymigbench.py` to check if it is working. You should see the following output: +If there is no error, run `python pymigbench.py` to check if it is working. You should see an output similar to the one below: ```yaml -- library pair: 59 - migration: 157 +- analogous library pairs: 59 + unique libraries: 99 + unique source libraries: 55 + unique target libraries: 56 + unique library domains: 13 + migrations: 157 + client repositories having migrations: 127 + library pairs having migrations: 49 + migration commits: 155 + migrations having code changes: 75 + library pairs having code changes: 34 + client repositories having code changes: 57 + commits having code changes: 74 + modified files: 161 + modified code segments: 375 ``` ## Query PyMigBench