Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
|
3fb79fcb30 | 1 year ago |
|
28d58c398a | 1 year ago |
|
a2eb549ba2 | 1 year ago |
|
b08b5434ac | 1 year ago |
|
210e4e4d4e | 1 year ago |
|
67c734aaf3 | 1 year ago |
|
efc86170a8 | 1 year ago |
|
7699c1b883 | 1 year ago |
|
9db264c0d1 | 1 year ago |
|
db866e7955 | 1 year ago |
|
d4eaefc03c | 1 year ago |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 844 KiB |
@ -0,0 +1,34 @@
|
|||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
|
import 'Music.dart';
|
||||||
|
|
||||||
|
class Capsule {
|
||||||
|
final String _id;
|
||||||
|
late Music _music;
|
||||||
|
Tuple2<String?,String?> _location;
|
||||||
|
DateTime _date;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
Capsule(this._id, this._location, this._date);
|
||||||
|
|
||||||
|
//Getters and setters
|
||||||
|
String get id => _id;
|
||||||
|
|
||||||
|
Music get music => _music;
|
||||||
|
|
||||||
|
set music(Music value) {
|
||||||
|
_music = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tuple2<String?, String?> get location => _location;
|
||||||
|
|
||||||
|
set location(Tuple2<String?, String?> value) {
|
||||||
|
_location = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime get date => _date;
|
||||||
|
|
||||||
|
set date(DateTime value) {
|
||||||
|
_date = value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
|
class CapsuleService {
|
||||||
|
Future<List<bool>> recapSevenDays(String id) async {
|
||||||
|
List<bool> recapList = [];
|
||||||
|
|
||||||
|
DateTime sevenDaysAgo = DateTime.now().subtract(Duration(days: 6));
|
||||||
|
|
||||||
|
QuerySnapshot<Map<String, dynamic>> response = await FirebaseFirestore
|
||||||
|
.instance
|
||||||
|
.collection("capsules")
|
||||||
|
.where("user_id", isEqualTo: id)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
List<Map<String, dynamic>?> capsuleList = response.docs
|
||||||
|
.map((DocumentSnapshot<Map<String, dynamic>> doc) => doc.data())
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
DateTime date = sevenDaysAgo.add(Duration(days: i));
|
||||||
|
bool capsuleExists = capsuleList.any((post) =>
|
||||||
|
post?["date"] != null &&
|
||||||
|
post?["date"].toDate().year == date.year &&
|
||||||
|
post?["date"].toDate().month == date.month &&
|
||||||
|
post?["date"].toDate().day == date.day);
|
||||||
|
|
||||||
|
recapList.add(capsuleExists);
|
||||||
|
}
|
||||||
|
|
||||||
|
return recapList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue