| 137 | |
| 138 | |
| 139 | class CommitDataCache: |
| 140 | def __init__(self, path="results/data.json"): |
| 141 | self.path = path |
| 142 | self.data = {} |
| 143 | if os.path.exists(path): |
| 144 | self.data = self.read_from_disk() |
| 145 | |
| 146 | def get(self, commit): |
| 147 | if commit not in self.data.keys(): |
| 148 | # Fetch and cache the data |
| 149 | self.data[commit] = get_features(commit) |
| 150 | self.write_to_disk() |
| 151 | return self.data[commit] |
| 152 | |
| 153 | def read_from_disk(self): |
| 154 | with open(self.path) as f: |
| 155 | data = json.load(f) |
| 156 | data = {commit: dict_to_features(dct) for commit, dct in data.items()} |
| 157 | return data |
| 158 | |
| 159 | def write_to_disk(self): |
| 160 | data = {commit: features._asdict() for commit, features in self.data.items()} |
| 161 | with open(self.path, "w") as f: |
| 162 | json.dump(data, f) |
| 163 | |
| 164 | |
| 165 | def get_commits_between(base_version, new_version): |
no outgoing calls
no test coverage detected
searching dependent graphs…