Skip to content

Commit

Permalink
Merge pull request #894 from bannzai/revert-892-fix/limit/history
Browse files Browse the repository at this point in the history
Revert "履歴の閲覧を180日間に制限する"
  • Loading branch information
bannzai authored Sep 4, 2023
2 parents d780b1d + 9c2db20 commit e5b19f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
9 changes: 4 additions & 5 deletions lib/entity/pill_sheet_modified_history.codegen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ extension PillSheetModifiedActionTypeFunctions on PillSheetModifiedActionType {
class PillSheetModifiedHistory with _$PillSheetModifiedHistory {
@JsonSerializable(explicitToJson: true)
const factory PillSheetModifiedHistory({
@JsonKey(includeIfNull: false, toJson: toNull) required String? id,
@JsonKey(includeIfNull: false, toJson: toNull)
required String? id,
required String actionType,
required PillSheetModifiedHistoryValue value,
// This is deprecated property.
Expand All @@ -68,12 +69,12 @@ class PillSheetModifiedHistory with _$PillSheetModifiedHistory {
fromJson: NonNullTimestampConverter.timestampToDateTime,
toJson: NonNullTimestampConverter.dateTimeToTimestamp,
)
required DateTime estimatedEventCausingDate,
required DateTime estimatedEventCausingDate,
@JsonKey(
fromJson: NonNullTimestampConverter.timestampToDateTime,
toJson: NonNullTimestampConverter.dateTimeToTimestamp,
)
required DateTime createdAt,
required DateTime createdAt,
}) = _PillSheetModifiedHistory;
const PillSheetModifiedHistory._();

Expand All @@ -84,8 +85,6 @@ class PillSheetModifiedHistory with _$PillSheetModifiedHistory {

// Factories
abstract class PillSheetModifiedHistoryServiceActionFactory {
static const limitDays = 180;

static PillSheetModifiedHistory _create({
required PillSheet? before,
required PillSheet? after,
Expand Down
16 changes: 0 additions & 16 deletions lib/provider/pill_sheet_modified_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pilll/provider/database.dart';
import 'package:pilll/entity/pill_sheet_modified_history.codegen.dart';
import 'package:pilll/utils/datetime/day.dart';

final pillSheetModifiedHistoriesProvider = StreamProvider.family.autoDispose((ref, DateTime? afterCursor) {
if (afterCursor != null) {
return ref
.watch(databaseProvider)
.pillSheetModifiedHistoriesReference()
.where(
PillSheetModifiedHistoryFirestoreKeys.estimatedEventCausingDate,
isLessThanOrEqualTo: today().add(const Duration(days: 1)),
isGreaterThanOrEqualTo: today().subtract(const Duration(days: PillSheetModifiedHistoryServiceActionFactory.limitDays)),
)
.orderBy(PillSheetModifiedHistoryFirestoreKeys.estimatedEventCausingDate, descending: true)
.startAfter([afterCursor])
.limit(20)
Expand All @@ -24,11 +18,6 @@ final pillSheetModifiedHistoriesProvider = StreamProvider.family.autoDispose((re
return ref
.watch(databaseProvider)
.pillSheetModifiedHistoriesReference()
.where(
PillSheetModifiedHistoryFirestoreKeys.estimatedEventCausingDate,
isLessThanOrEqualTo: today().add(const Duration(days: 1)),
isGreaterThanOrEqualTo: today().subtract(const Duration(days: PillSheetModifiedHistoryServiceActionFactory.limitDays)),
)
.orderBy(PillSheetModifiedHistoryFirestoreKeys.estimatedEventCausingDate, descending: true)
.limit(20)
.snapshots()
Expand All @@ -40,11 +29,6 @@ final pillSheetModifiedHistoriesWithLimitProvider = StreamProvider.family((ref,
return ref
.watch(databaseProvider)
.pillSheetModifiedHistoriesReference()
.where(
PillSheetModifiedHistoryFirestoreKeys.estimatedEventCausingDate,
isLessThanOrEqualTo: today().add(const Duration(days: 1)),
isGreaterThanOrEqualTo: today().subtract(const Duration(days: PillSheetModifiedHistoryServiceActionFactory.limitDays)),
)
.orderBy(PillSheetModifiedHistoryFirestoreKeys.estimatedEventCausingDate, descending: true)
.limit(limit)
.snapshots()
Expand Down

0 comments on commit e5b19f7

Please sign in to comment.