Conversation
ghost
commented
Aug 8, 2018
- simplify logic for the view of report page
- update the logic of the angular controller to use variables instead of $scope
- create a table model and add it to the reportsdb context
- add a method of saving the jira users from all the instance's projects into the db table
| .Select(ToAtlassianUser) | ||
| .ToList(); | ||
|
|
||
| var dbUsers = db.AtlassianUser.ToList(); |
There was a problem hiding this comment.
does this mean that you retrieve ALL users from the database?
| { | ||
| using (var db = new ReportsDb()) | ||
| { | ||
| var users = GetUsersFromInstance(db, instanceId) |
There was a problem hiding this comment.
var jiraContexts = db.Settings.select( ... )
var users = GetUsers(jiraContexts )
UpdateUsers()
There was a problem hiding this comment.
I think this call here is a little problematic, because the connection to the database stays open all time, until the requests to JIRA complete, which might take some time, keeping in mind that there are several users to download. So it would be better to get the necessary data in one request, and then close the db connection, then fetch the users from JIRA, and then open a new connection to the db to update the users.
Sebyd
left a comment
There was a problem hiding this comment.
So add the mapping AtlassianUser -> Instance and then refactor this part.
| namespace Equilobe.DailyReport.Models.Storage | ||
| { | ||
| public class AtlassianUser | ||
| { |
There was a problem hiding this comment.
This is not enough. You need to connect the AtlassianUser to a jira instance. Create a many to many map (because one user can be part of multiple instances)
There was a problem hiding this comment.
Or better, let's not make the many to many map. Let's just use InstanceId as a foreign key. Because if there is another jira instance, it will be a different app client. So I think it is better this way. And if the AtlassianUsers get duplicated, it should be no problem. But we need to link it to the InstalledInstance entity.
There was a problem hiding this comment.
Ok. I think UserImage is obsolete in this case, now that we have the AtlassianUser that has the same things. Maybe we can phase that out in a different task/PR
There was a problem hiding this comment.
Sure. I created a new task in Jira for this
| #region IJiraService Implementation | ||
| public void UpdateDashboardData(long instanceId) | ||
| { | ||
| var projects = GetProjectsFromInstance(instanceId); |
There was a problem hiding this comment.
We won't use this. If we get the users per instance we do not to get them from their projects and then add them. Just get directly the users from one instance.
There was a problem hiding this comment.
There is no jira api request to get all the users from the instance. There is a workaround by making a search through multiple projects, but the projects keys are needed, so we must make a request to get the projects keys. Using the search could mean only one request, not making a request per project, which would be faster, but i would need to make a request to get projects keys.
I will try it now
There was a problem hiding this comment.
Actually, I now have looked more into it, and the method searching in all projects is meant for getting the users who are members in all projects, not get all of the member from all the projects. So there is no other way than to get manually, from each project, the members
There was a problem hiding this comment.
Hmm. Ok. I see that there are some ways to get the users, but they do not seem reliable. One of them would be to use ' /search?username=%' but I've seen that it doesn't work in all Jira versions, so it doesn't seem that reliable.
There was a problem hiding this comment.
There was a problem hiding this comment.
I've tried this. But I think I might get a way to get all the users with one call.
There was a problem hiding this comment.
@rungureanu-eq That is the same thing that I suggested, but from what I read, this changed from version to version. So it is not very reliable.
|
|
||
| using (var db = new ReportsDb()) | ||
| { | ||
| var dbUsers = db.AtlassianUser.ToList(); |
There was a problem hiding this comment.
Here you update the dashboard for one instance and you take from db all the users. Take only the users which have the instance id of the dashboard.
| public IJiraService JiraService { get; set; } | ||
|
|
||
| #region IReportService Implementation | ||
| public void UpdateDashboardData(long instanceId) |
There was a problem hiding this comment.
This method is called UpdateDashboardData but I see that you update the users. Change the name of the method. Or if this method will call all the other methods that do updates, extract the users part in a separate method and call it in here.
There was a problem hiding this comment.
Initially, I thought about a method which updates the dashboard data, including users, worklogs, comments and so on. But yeah, you are right, the name of the method does not stand for what it does. I created a new method for what I was working on and called that method inside this one.
| return ResolveRequest<Project>(request); | ||
| } | ||
|
|
||
| public List<JiraUser> GetInstanceUsers() |
There was a problem hiding this comment.
Rename this to GetUsers or GetAllUsers
|
|
||
| public List<JiraUser> GetInstanceUsers() | ||
| { | ||
| var request = new RestRequest(JiraApiUrls.InstanceUsers(), Method.GET); |
There was a problem hiding this comment.
same with JiraApiUrls -> Users instead of InstanceUsers
| return new TimesheetGenerator(client).GetTimesheetIssuesForAuthor(context.ProjectKey, context.TargetUser, context.StartDate, context.EndDate); | ||
| } | ||
|
|
||
| public List<JiraUser> GetInstanceUsers(JiraRequestContext context) |
| public string Avatar32x32 { get; set; } | ||
| public string Avatar24x24 { get; set; } | ||
| public string Avatar16x16 { get; set; } | ||
|
|
There was a problem hiding this comment.
Add IsActive to the user. So that we also get this info from jira.
| }; | ||
| } | ||
|
|
||
| private void UpdateDbUser(AtlassianUser dbUser, AtlassianUser updatedUser, long instanceId) |
There was a problem hiding this comment.
The instanceId should not be here as a parameter. This property on the user should never change. we work inside an instance here.