Skip to content

Commit

Permalink
improve the summary query
Browse files Browse the repository at this point in the history
  • Loading branch information
mohayemin committed Jan 26, 2023
1 parent 2221f5f commit eb3c721
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 9 deletions.
51 changes: 47 additions & 4 deletions code/query/Summary.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 15 additions & 2 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:**
Expand Down
1 change: 1 addition & 0 deletions docs/run_site.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bundle exec jekyll serve
19 changes: 16 additions & 3 deletions docs/tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb3c721

Please sign in to comment.