More modal solution

This commit is contained in:
eraden 2021-10-16 10:46:27 +02:00
parent 36bbaefb23
commit e390ce62b5

View File

@ -54,7 +54,7 @@ impl ProjectPage {
&& issue_filter_with_text(issue, page.text_filter.as_str()) && issue_filter_with_text(issue, page.text_filter.as_str())
&& issue_filter_with_only_my(issue, page.only_my_filter, user) && issue_filter_with_only_my(issue, page.only_my_filter, user)
}); });
let mut issues = if page.recently_updated_filter { let mut issues: Vec<&Issue> = if page.recently_updated_filter {
let mut m = HashMap::new(); let mut m = HashMap::new();
let mut sorted: Vec<(IssueId, NaiveDateTime)> = issues let mut sorted: Vec<(IssueId, NaiveDateTime)> = issues
.map(|issue| { .map(|issue| {
@ -63,19 +63,17 @@ impl ProjectPage {
}) })
.collect(); .collect();
sorted.sort_by(|(_, a_time), (_, b_time)| a_time.cmp(b_time)); sorted.sort_by(|(_, a_time), (_, b_time)| a_time.cmp(b_time));
let mut issues: Vec<&Issue> = sorted sorted
.into_iter() .into_iter()
.take(10) .take(10)
.flat_map(|(id, _)| m.remove(&id)) .flat_map(|(id, _)| m.remove(&id))
.collect(); .collect()
issues.sort_by(|a, b| a.list_position.cmp(&b.list_position));
issues
} else { } else {
issues.collect() issues.collect()
}; };
issues.sort_by(|a, b| a.list_position.cmp(&b.list_position)); issues.sort_by(|a, b| a.list_position.cmp(&b.list_position));
let issues_per_epic_id = {
let issues_per_epic_id =
issues issues
.into_iter() .into_iter()
.fold(HashMap::with_capacity(num_of_epics), |mut m, issue| { .fold(HashMap::with_capacity(num_of_epics), |mut m, issue| {
@ -83,20 +81,16 @@ impl ProjectPage {
.or_insert_with(|| Vec::with_capacity(100)) .or_insert_with(|| Vec::with_capacity(100))
.push(issue); .push(issue);
m m
}) });
};
epics epics
.map(|epic| { .map(|epic| EpicIssuePerStatus {
let mut per_epic_map = EpicIssuePerStatus {
epic_ref: epic.map(|(id, name, starts_at, ends_at)| { epic_ref: epic.map(|(id, name, starts_at, ends_at)| {
(id, name.to_string(), starts_at, ends_at) (id, name.to_string(), starts_at, ends_at)
}), }),
..Default::default() per_status_issues: statuses
}; .iter()
.map(|(current_status_id, issue_status_name)| StatusIssueIds {
for (current_status_id, issue_status_name) in statuses.iter() {
let per_status_map = StatusIssueIds {
status_id: *current_status_id, status_id: *current_status_id,
status_name: issue_status_name.to_string(), status_name: issue_status_name.to_string(),
issue_ids: issues_per_epic_id issue_ids: issues_per_epic_id
@ -108,10 +102,8 @@ impl ProjectPage {
.collect() .collect()
}) })
.unwrap_or_default(), .unwrap_or_default(),
}; })
per_epic_map.per_status_issues.push(per_status_map); .collect(),
}
per_epic_map
}) })
.collect() .collect()
} }