chore: remove Firebase dependencies and legacy code (Fase 4)

- Delete all firebase_*_repository.dart files (replaced by api_* equivalents)
- Remove cloud_firestore, firebase_auth, firebase_storage, firebase_core from all package pubspecs
- Remove cloud_firestore from main pubspec.yaml
- Delete firebase_options.dart (no longer referenced)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-17 18:11:31 -05:00
co-authored by Claude Sonnet 4.6
parent 733384091c
commit af91e0ba04
18 changed files with 0 additions and 1120 deletions
@@ -1,116 +0,0 @@
import 'dart:async';
import 'dart:developer';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:score_repository/score_repository.dart';
import 'package:score_repository/src/entities/comment_entity.dart';
class FirebaseScoreRepository {
final reputationsCollection =
FirebaseFirestore.instance.collection('reputations');
final commentsCollection = FirebaseFirestore.instance.collection('comments');
ReputationEntity? _reputation;
final StreamController<ReputationEntity> _reputationController =
StreamController<ReputationEntity>.broadcast();
Stream<ReputationEntity> streamReputation() {
return _reputationController.stream;
}
FirebaseScoreRepository() {
FirebaseAuth.instance.userChanges().listen((user) async {
if (user != null) {
final reputation = await getReputationByUserId(user.uid);
_reputation = reputation;
} else {
_reputation = null;
}
_reputationController.add(_reputation ??
const ReputationEntity(
total: 0,
average: 0,
totalPro: 0,
averagePro: 0,
));
});
}
ReputationEntity getReputation() {
return _reputation ??
const ReputationEntity(
total: 0,
average: 0,
totalPro: 0,
averagePro: 0,
);
}
Future<ReputationEntity> getReputationByUserId(String userId) async {
try {
final snap = await reputationsCollection.doc(userId).get();
return ReputationEntity.fromDocument(snap.data()!);
} catch (e) {
log(e.toString());
return const ReputationEntity(
total: 0,
average: 0,
totalPro: 0,
averagePro: 0,
);
}
}
Stream<List<CommentEntity>> getScoresForUser(String userId) {
return commentsCollection
.where('destination_id', isEqualTo: userId)
.where('is_from_user', isEqualTo: false)
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => CommentEntity.fromDocument(doc.data()))
.toList());
}
Stream<List<CommentEntity>> getScoresForProfessional(String userId) {
return commentsCollection
.where('destination_id', isEqualTo: userId)
.where('is_from_user', isEqualTo: true)
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => CommentEntity.fromDocument(doc.data()))
.toList());
}
addComment(CommentEntity comment) async {
await commentsCollection.add(comment.toDocument());
final query = await commentsCollection
.where('destination_id', isEqualTo: comment.destinationId)
.where('is_from_user', isEqualTo: comment.isFromUser)
.get();
var total = 0.0;
var count = 0;
for (var doc in query.docs) {
final comment = CommentEntity.fromDocument(doc.data());
total += comment.score;
count++;
}
if (count > 0) {
final average = total / count;
if (comment.isFromUser) {
await reputationsCollection.doc(comment.destinationId).set(
{'total_pro': count, 'average_pro': average},
SetOptions(merge: true));
} else {
await reputationsCollection.doc(comment.destinationId).set({
'total': count,
'average': average,
}, SetOptions(merge: true));
}
}
}
}
-4
View File
@@ -14,10 +14,6 @@ dependencies:
http: ^1.1.0
shared_preferences: ^2.0.10
# Firebase kept for FirebaseScoreRepository (legacy) and CommentEntity uses Timestamp
cloud_firestore: ^4.15.4
firebase_core: ^2.25.4
firebase_auth: ^4.17.4
dev_dependencies:
flutter_lints: ^2.0.0