From 6c473af261e1bcea7d711108796de5458fce3388 Mon Sep 17 00:00:00 2001 From: emkartal1 Date: Tue, 1 Aug 2023 23:24:54 +0200 Subject: [PATCH 1/6] Improved functions --- .../justMUSIC/lib/services/PostService.dart | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sources/justMUSIC/lib/services/PostService.dart b/Sources/justMUSIC/lib/services/PostService.dart index 9aff8e2..7e71ff4 100644 --- a/Sources/justMUSIC/lib/services/PostService.dart +++ b/Sources/justMUSIC/lib/services/PostService.dart @@ -46,7 +46,7 @@ class PostService { {int limit = 10, int offset = 0}) async { DateTime twentyFourHoursAgo = DateTime.now().subtract(Duration(hours: 24)); Timestamp twentyFourHoursAgoTimestamp = - Timestamp.fromDate(twentyFourHoursAgo); + Timestamp.fromDate(twentyFourHoursAgo); QuerySnapshot> response = await FirebaseFirestore .instance @@ -62,22 +62,22 @@ class PostService { return filteredPosts; } + Timestamp _getTwentyFourHoursAgoTimestamp() { + DateTime twentyFourHoursAgo = DateTime.now().subtract(Duration(hours: 24)); + return Timestamp.fromDate(twentyFourHoursAgo); + } + Future>>> getPostsFriends( {int limit = 10, int offset = 0}) async { - var response = await FirebaseFirestore - .instance + var timestamp = _getTwentyFourHoursAgoTimestamp(); + var response = await FirebaseFirestore.instance .collection("posts") .where("user_id", whereIn: MyApp.userViewModel.userCurrent.followed) + .where("date", isGreaterThan: timestamp) + .orderBy("date") .limit(limit) .get(); - response.docs.sort((a, b) { - DateTime aDate = a.data()['date'].toDate(); - DateTime bDate = b.data()['date'].toDate(); - - return bDate.compareTo(aDate); - }); - return response.docs; } From f758136e082e3cd1dec95787b64c4ae9729a74ac Mon Sep 17 00:00:00 2001 From: emkartal1 Date: Tue, 1 Aug 2023 23:31:10 +0200 Subject: [PATCH 2/6] Fix error :bug: --- .../justMUSIC/lib/view_model/PostViewModel.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/justMUSIC/lib/view_model/PostViewModel.dart b/Sources/justMUSIC/lib/view_model/PostViewModel.dart index e74ab19..d60a4ce 100644 --- a/Sources/justMUSIC/lib/view_model/PostViewModel.dart +++ b/Sources/justMUSIC/lib/view_model/PostViewModel.dart @@ -36,11 +36,12 @@ class PostViewModel { ids.add(value.data()["song_id"]); return PostMapper.toModel(value); }).toList(); - _postsFriends = await Future.wait(postsFutures); + var posts = await Future.wait(postsFutures); List musics = await MyApp.musicViewModel.getMusicsWithIds(ids); - for (int i = 0; i < _postsFriends.length; i++) { - _postsFriends[i].music = musics[i]; + for (int i = 0; i < posts.length; i++) { + posts[i].music = musics[i]; } + _postsFriends = posts; return _postsFriends; } catch (e) { print(e); @@ -61,11 +62,12 @@ class PostViewModel { ids.add(value.data()["song_id"]); return PostMapper.toModel(value); }).toList(); - _bestPosts = await Future.wait(postsFutures); + var posts = await Future.wait(postsFutures); List musics = await MyApp.musicViewModel.getMusicsWithIds(ids); - for (int i = 0; i < _bestPosts.length; i++) { - _bestPosts[i].music = musics[i]; + for (int i = 0; i < posts.length; i++) { + posts[i].music = musics[i]; } + _bestPosts = posts; return _bestPosts; } catch (e) { print(e); From 3563ba8d108e4407b02b06bf9e6f234c67ee1b18 Mon Sep 17 00:00:00 2001 From: Emre KARTAL Date: Wed, 2 Aug 2023 12:51:48 +0200 Subject: [PATCH 3/6] Add .drone.yml --- .drone.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1a15aa4 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,29 @@ +kind: pipeline +type: docker +name: JustMusic + +trigger: + event: + - push + +steps: + - name: app-build + image: cirrusci/flutter:stable + commands: + - cd ./Sources/justMUSIC/ + - flutter build apk + + - name: code-analysis + image: cirrusci/flutter:stable + environment: + SONAR_TOKEN: + from_secret: SONAR_TOKEN + commands: + - export SONAR_SCANNER_VERSION=4.7.0.2747 + - export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux + - curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip + - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ + - export PATH=$SONAR_SCANNER_HOME/bin:$PATH + - export SONAR_SCANNER_OPTS="-server" + - sonar-scanner -D sonar.projectKey=JustMusic -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar + depends_on: [ app-build ] \ No newline at end of file From 94e08624c03652b5e386cdf4b6c393d84a3d24c2 Mon Sep 17 00:00:00 2001 From: Emre KARTAL Date: Wed, 2 Aug 2023 12:55:17 +0200 Subject: [PATCH 4/6] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 1a15aa4..241285b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,5 +25,4 @@ steps: - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - export SONAR_SCANNER_OPTS="-server" - - sonar-scanner -D sonar.projectKey=JustMusic -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar - depends_on: [ app-build ] \ No newline at end of file + - sonar-scanner -D sonar.projectKey=JustMusic -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar \ No newline at end of file From 970e29ee1b963a77c08a9941e9743c6765b05a57 Mon Sep 17 00:00:00 2001 From: Emre KARTAL Date: Wed, 2 Aug 2023 12:56:07 +0200 Subject: [PATCH 5/6] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 241285b..f43b97f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,11 +7,11 @@ trigger: - push steps: - - name: app-build - image: cirrusci/flutter:stable - commands: - - cd ./Sources/justMUSIC/ - - flutter build apk +# - name: app-build +# image: cirrusci/flutter:stable +# commands: +# - cd ./Sources/justMUSIC/ +# - flutter build apk - name: code-analysis image: cirrusci/flutter:stable From 366bcb24174efb10699fa67b947ccda8cd61a653 Mon Sep 17 00:00:00 2001 From: Emre KARTAL Date: Wed, 2 Aug 2023 13:02:41 +0200 Subject: [PATCH 6/6] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index f43b97f..6a35e64 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,4 +25,4 @@ steps: - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - export SONAR_SCANNER_OPTS="-server" - - sonar-scanner -D sonar.projectKey=JustMusic -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar \ No newline at end of file + - sonar-scanner -D sonar.projectKey=JustMusic -D sonar.sources=./Sources/justMUSIC -D sonar.host.url=https://codefirst.iut.uca.fr/sonar \ No newline at end of file