Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented storing and getting data #23

Merged
merged 4 commits into from
Oct 2, 2020
Merged

Conversation

rickvdbosch
Copy link
Collaborator

Implemented storing user info
Implemented getting user info (including nested classes structure for the viewmodel)
Not entirely happy with the code yet (there's room for optimization), but created PR so others can check, test and improve if necessary

Closes #16

Copy link
Owner

@Layla-P Layla-P left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some decomposition needed :-)

_logger.LogTrace($"Sending request to Github for pull requests on repositoy: {name}");
var prs = await _client.PullRequest.GetAllForRepository(owner, name, new PullRequestRequest() { State = ItemStateFilter.All });

return prs.Select(pr => new Models.DTOs.PullRequest(pr.Number, pr.Url)).ToList();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Rick!
Can we return a var listOfPrs for example instead of directly returning the select statement as it makes it easier for less expreienced developers to read and understand, imo.
Same goes for the rest of the methods here.

_logger.LogTrace($"Sending request to Github for repositories belonging to user: {owner}");
var repositories = await _client.Repository.GetAllForUser(owner);

return repositories.Select(r => new Models.DTOs.Repository(owner, r.Name, r.Url)).ToList();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a namespace conflict or could we move Models.DTOs to a using statement?

Comment on lines 56 to +83
var info = entity.RowKey.Split(':', StringSplitOptions.RemoveEmptyEntries);
// TODO: implement splitting the entities into a class-structure for the frontend model
if (info.Length != 3)
{
// TODO: define how to proceed with this.. this is corrupted data!
continue;
}
var owner = info[0];
var repoName = info[1];
var prId = int.Parse(info[2]);

Repository repo;
var temp = user.RepositoryPrAddedTo
.FirstOrDefault(repo => repo.Owner.Equals(owner, StringComparison.OrdinalIgnoreCase) &&
repo.Name.Equals(repoName, StringComparison.OrdinalIgnoreCase));
if (temp != null)
{
repo = temp;
}
else
{
repo = new Repository(owner, repoName, entity.Url, new List<PullRequest>());
add = true;
}
var prs = entities.Where(e => e.RowKey.StartsWith($"{owner}:{repoName}", StringComparison.OrdinalIgnoreCase));
foreach (var pr in prs)
{
var id = int.Parse(pr.RowKey.Substring(pr.RowKey.LastIndexOf(':') + 1));
if (!repo.Prs.Any(pr => pr.PrId == id))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of code happening in this method. I would like it decomposed into smaller units to keep it all more solid.

@Layla-P Layla-P merged commit 2c11ceb into Layla-P:dev Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Current structure might hit limits
2 participants