-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
Implemented getting information
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
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)) |
There was a problem hiding this comment.
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.
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