Compare commits
No commits in common. 'master' and 'FIX/FEED_PAGINATION' have entirely different histories.
master
...
FIX/FEED_P
Before Width: | Height: | Size: 162 KiB |
Before Width: | Height: | Size: 844 KiB |
@ -1,34 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,33 +0,0 @@
|
|||||||
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