diff --git a/ui/src/database/database.js b/ui/src/database/database.js index 324b81cb..6a17d788 100644 --- a/ui/src/database/database.js +++ b/ui/src/database/database.js @@ -20,6 +20,14 @@ export default class Database { } } + static async getCommitsWithFileTree(commitSpan, significantSpan) { + if (await this.checkBackendConnection()) { + return ServerDB.getCommitsWithFileTree(commitSpan, significantSpan); + } else { + //return LocalDB.getCommitWithFileTree(commitSpan, significantSpan); + } + } + static async getCommitData(commitSpan, significantSpan) { if (await this.checkBackendConnection()) { return ServerDB.getCommitData(commitSpan, significantSpan); diff --git a/ui/src/database/serverDB.js b/ui/src/database/serverDB.js index 48e9785d..0d4cdddf 100644 --- a/ui/src/database/serverDB.js +++ b/ui/src/database/serverDB.js @@ -20,6 +20,10 @@ export default class ServerDB { return Builds.getBuildData(commitSpan, significantSpan); } + static getCommitsWithFileTree(commitSpan, significantSpan) { + return Commits.getCommitsWithFileTree(commitSpan, significantSpan); + } + static getIssueData(issueSpan, significantSpan) { return Issues.getIssueData(issueSpan, significantSpan); } diff --git a/ui/src/database/serverDB/commits.js b/ui/src/database/serverDB/commits.js index 20e7011b..d1641d8e 100644 --- a/ui/src/database/serverDB/commits.js +++ b/ui/src/database/serverDB/commits.js @@ -32,7 +32,6 @@ export default class Commits { ) .then((resp) => resp.commits); }; - return traversePages(getCommitsPage(significantSpan[0], significantSpan[1]), (commit) => { commitList.push(commit); }).then(function () { @@ -40,6 +39,78 @@ export default class Commits { }); } + static getCommitsWithFileTree(commitSpan, significantSpan) { + const commitList = []; + const commitsWithFileTree = (since, until) => (page, perPage) => { + return graphQl + .query( + `query($page: Int, $perPage: Int, $since: Timestamp, $until: Timestamp) { + commits(page: $page, perPage: $perPage, since: $since, until: $until) { + count + page + perPage + data { + sha + date + messageHeader + signature + stats { + additions + deletions + } + files { + data { + stats { + additions + deletions + } + file { + path, + } + lineCount + } + } + } + } + }`, + { page, perPage, since, until } + ) + .then((resp) => resp.commits); + }; + + return traversePages(commitsWithFileTree(significantSpan[0], significantSpan[1]), (commit) => { + commitList.push(commit); + }).then(function () { + return commitList; + }); + } + static searchCommits(text) { //TODO richtige Query schreiben + /* + const commitList = []; + + const getCommitPageSearch = (text) => (page, perPage) => { + return graphQl + .query( + ` + query($q: String) { + commits(page: 1, perPage: 50, q: $q, sort: "DESC") { + data { iid title createdAt closedAt } + } + }`, + { q: text } + ) + .then((resp) => resp.data); + }; + + return traversePages(getCommitPageSearch(text), (commit) => { + commitList.push(commit); + }).then(function () { + return commitList; + });*/ + } + + + static getCommitDataOwnershipRiver(commitSpan, significantSpan, granularity, interval) { const statsByAuthor = {};