From ebf9aa56f71d33574945d46b5f1f3075b7b7c43d Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 13:57:08 +0100
Subject: [PATCH 1/7] fix(news): issue on news display

---
 .gitlab-ci.yml                                | 10 +++++++++
 .../post-list/post-list.component.ts          | 21 +++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3564df811..305699380 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,6 +3,16 @@ stages:
   - build
   - deploy
 
+variables:
+  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
+
+build_branche:
+  stage: build
+  script:
+    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+    - docker build -t $IMAGE_TAG .
+    - docker push $IMAGE_TAG
+
 build:
   image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
   services:
diff --git a/src/app/post/components/post-list/post-list.component.ts b/src/app/post/components/post-list/post-list.component.ts
index 77a3b17da..102dd4a75 100644
--- a/src/app/post/components/post-list/post-list.component.ts
+++ b/src/app/post/components/post-list/post-list.component.ts
@@ -61,14 +61,22 @@ export class PostListComponent implements OnInit {
       } else {
         // Init default news list
         this.postService.getPosts(1).subscribe((news) => {
-          this.setNews(news);
-          const headLineTag = this.allPosts.find((post: Post) => post.tags.some((tag) => tag.slug === TagEnum.aLaUne));
-          this.allPosts.unshift(headLineTag);
+          this.fillArticles(news);
         });
       }
     });
   }
 
+  public fillArticles(news: PostWithMeta): void {
+    this.setNews(news);
+    const headLineTag = this.allPosts.filter((post: Post) => post.tags.some((tag) => tag.slug === TagEnum.aLaUne));
+
+    const headIndex = this.allPosts.findIndex((post) => post.id === headLineTag[0].id);
+    this.allPosts.splice(headIndex, 1);
+
+    this.allPosts = [...headLineTag, ...this.allPosts];
+  }
+
   public getPosts(filters?: Tag[]): void {
     // Parse filter
     let parsedFilters = null;
@@ -87,7 +95,7 @@ export class PostListComponent implements OnInit {
 
     this.isLoading = true;
     this.postService.getPosts(1, parsedFilters).subscribe((news) => {
-      this.setNews(news);
+      this.fillArticles(news);
     });
   }
 
@@ -121,7 +129,7 @@ export class PostListComponent implements OnInit {
     if (this.pagination && this.pagination.page < this.pagination.pages) {
       this.isLoading = true;
       this.postService.getPosts(this.pagination.next).subscribe((news) => {
-        this.setNews(news);
+        this.fillArticles(news);
       });
     }
   }
@@ -130,11 +138,12 @@ export class PostListComponent implements OnInit {
   private setNews(news: PostWithMeta): void {
     this.pagination = news.meta.pagination;
     const customIndex = this.allPosts.length; // For scroll loading, start with previous index.
-    this.allPosts = news.posts.map((val, index) => {
+    const newPosts = news.posts.map((val, index) => {
       val = this.addAuthorToPost(val);
       index += customIndex;
       return val;
     });
+    this.allPosts = [...this.allPosts, ...newPosts];
     this.isLoading = false;
   }
 
-- 
GitLab


From 1e3d6c3f88a48799e698a93a3eeccd317ee4b303 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 13:59:00 +0100
Subject: [PATCH 2/7] fix: gitlab-ci

---
 .gitlab-ci.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 305699380..e621d4e1f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,7 +6,8 @@ stages:
 variables:
   IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
 
-build_branche:
+build_branch:
+  image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
   stage: build
   script:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-- 
GitLab


From 5610a9a05809108d57c5b76b9b397d509e241139 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 14:00:24 +0100
Subject: [PATCH 3/7] fix: cicd

---
 .gitlab-ci.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e621d4e1f..8172cc385 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -8,6 +8,8 @@ variables:
 
 build_branch:
   image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
+  services:
+    - docker:18.09-dind
   stage: build
   script:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-- 
GitLab


From e729512664af01f1cc0b22b86f31deabd6344d68 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 14:04:04 +0100
Subject: [PATCH 4/7] cicd

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8172cc385..29df2fb39 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,7 +13,7 @@ build_branch:
   stage: build
   script:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-    - docker build -t $IMAGE_TAG .
+    - docker build --pull -t "$IMAGE_TAG" --build-arg conf=prod .
     - docker push $IMAGE_TAG
 
 build:
-- 
GitLab


From c67be5cd8c138160142e5dce87cda51ea119bbf8 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 14:06:40 +0100
Subject: [PATCH 5/7] fix

---
 .gitlab-ci.yml | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 29df2fb39..399042ce3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,9 +3,6 @@ stages:
   - build
   - deploy
 
-variables:
-  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
-
 build_branch:
   image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
   services:
@@ -13,7 +10,7 @@ build_branch:
   stage: build
   script:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-    - docker build --pull -t "$IMAGE_TAG" --build-arg conf=prod .
+    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" --build-arg conf=prod .
     - docker push $IMAGE_TAG
 
 build:
-- 
GitLab


From 2438d3f0669840e4cca78b51e28274fd25d0685d Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 14:08:51 +0100
Subject: [PATCH 6/7] fix

---
 .gitlab-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 399042ce3..ad45cecd1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,8 +10,8 @@ build_branch:
   stage: build
   script:
     - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
-    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" --build-arg conf=prod .
-    - docker push $IMAGE_TAG
+    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" --build-arg conf=prod .
+    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
 
 build:
   image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/docker:18.09
-- 
GitLab


From f2972dd4af357db2d66fe381f6221ee65c6020e3 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 7 Feb 2022 14:47:59 +0100
Subject: [PATCH 7/7] fix

---
 src/app/post/components/post-list/post-list.component.ts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/app/post/components/post-list/post-list.component.ts b/src/app/post/components/post-list/post-list.component.ts
index 102dd4a75..e0e7f0e46 100644
--- a/src/app/post/components/post-list/post-list.component.ts
+++ b/src/app/post/components/post-list/post-list.component.ts
@@ -60,6 +60,7 @@ export class PostListComponent implements OnInit {
         this.getPosts(this.filters);
       } else {
         // Init default news list
+        this.allPosts = [];
         this.postService.getPosts(1).subscribe((news) => {
           this.fillArticles(news);
         });
-- 
GitLab