minor fixes
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

This commit is contained in:
Mylloon 2023-04-12 01:32:42 +02:00
parent addf6e0035
commit fac3e89d1c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 14 additions and 8 deletions

View file

@ -45,6 +45,8 @@ pub async fn get_page(config: Config) -> std::string::String {
let data = match fetch_pr().await { let data = match fetch_pr().await {
Ok(projects) => { Ok(projects) => {
let mut data: Vec<Project> = Vec::new(); let mut data: Vec<Project> = Vec::new();
// Grouping PRs by projects
let mut map: HashMap<&str, Vec<Pull>> = HashMap::new(); let mut map: HashMap<&str, Vec<Pull>> = HashMap::new();
projects.iter().for_each(|p| { projects.iter().for_each(|p| {
let project = Pull { let project = Pull {
@ -68,6 +70,7 @@ pub async fn get_page(config: Config) -> std::string::String {
} }
}); });
// Distributes each PR in the right vector
data.iter_mut().for_each(|d| { data.iter_mut().for_each(|d| {
map.get(d.name.as_str()).unwrap().iter().for_each(|p| { map.get(d.name.as_str()).unwrap().iter().for_each(|p| {
let state = p.state.into(); let state = p.state.into();
@ -82,6 +85,13 @@ pub async fn get_page(config: Config) -> std::string::String {
d.name = name.into_iter().collect(); d.name = name.into_iter().collect();
}); });
// Ascending order
data.iter_mut().for_each(|d| {
d.pulls_closed.reverse();
d.pulls_merged.reverse();
d.pulls_open.reverse();
});
PortfolioTemplate { PortfolioTemplate {
error: false, error: false,
projects: data projects: data

View file

@ -18,21 +18,17 @@
</p> </p>
{{/projects}} {{/projects}}
<h1 class="subtitle">En attente</h1> <h1 class="subtitle">En attente</h1>
{{#waiting}}
<p> <p>
{{#pulls_open}} {{#waiting}} {{#pulls_open}}
<a href="{{url}}">{{name}}#{{id}}</a> <a href="{{url}}">{{name}}#{{id}}</a>
{{/pulls_open}} {{/pulls_open}} {{/waiting}}
</p> </p>
{{/waiting}}
<h1 class="subtitle">Non mergées</h1> <h1 class="subtitle">Non mergées</h1>
{{#closed}}
<p> <p>
{{#pulls_closed}} {{#closed}} {{#pulls_closed}}
<a href="{{url}}">{{name}}#{{id}}</a> <a href="{{url}}">{{name}}#{{id}}</a>
{{/pulls_closed}} {{/pulls_closed}} {{/closed}}
</p> </p>
{{/closed}}
</div> </div>
{{/error}} {{/data}} {{> footer.html }} {{/error}} {{/data}} {{> footer.html }}
</body> </body>