Skip to content

Commit

Permalink
#59: Made function to get file tree with commits
Browse files Browse the repository at this point in the history
  • Loading branch information
profjellybean committed Dec 2, 2022
1 parent d95c4e6 commit 92c153a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ui/src/database/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions ui/src/database/serverDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
73 changes: 72 additions & 1 deletion ui/src/database/serverDB/commits.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,85 @@ export default class Commits {
)
.then((resp) => resp.commits);
};

return traversePages(getCommitsPage(significantSpan[0], significantSpan[1]), (commit) => {
commitList.push(commit);
}).then(function () {
return commitList;
});
}

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 = {};

Expand Down

0 comments on commit 92c153a

Please sign in to comment.