Merge remote-tracking branch 'origin/master'

pull/40/head
Lucas Delanier 2 years ago
commit 5de5f0c964

@ -0,0 +1,28 @@
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=./Sources/justMUSIC -D sonar.host.url=https://codefirst.iut.uca.fr/sonar

@ -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<Map<String, dynamic>> 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<List<QueryDocumentSnapshot<Map<String, dynamic>>>> 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;
}

@ -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<Music> 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<Music> 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);

Loading…
Cancel
Save