def handle(self, pillow_name, **options): confirm( "Are you sure you want to reset the checkpoint for the '{}' pillow?" .format(pillow_name)) confirm("Have you stopped the pillow?") pillow = get_pillow_by_name(pillow_name) if not pillow: raise CommandError( "No pillow found with name: {}".format(pillow_name)) checkpoint = pillow.checkpoint store = HistoricalPillowCheckpoint.get_historical_max( checkpoint.checkpoint_id) if not store: print( "No new sequence exists for that pillow. You'll have to do it manually." ) exit() old_seq = pillow.get_last_checkpoint_sequence() new_seq = store.seq confirm( "\nReset checkpoint for '{}' pillow from:\n\n{}\n\nto\n\n{}\n\n". format(pillow_name, old_seq, new_seq)) checkpoint.update_to(new_seq) print("Checkpoint updated")
def check_for_rewind(checkpoint): historical_checkpoint = HistoricalPillowCheckpoint.get_historical_max(checkpoint.checkpoint_id) if not historical_checkpoint: return False db_seq = checkpoint.get_current_sequence_id() store_seq = historical_checkpoint.seq_int has_rewound = force_seq_int(db_seq) < store_seq - EPSILON return has_rewound, historical_checkpoint.seq
def handle(self, pillow_name, **options): confirm("Are you sure you want to reset the checkpoint for the '{}' pillow?".format(pillow_name)) confirm("Have you stopped the pillow?") pillow = get_pillow_by_name(pillow_name) if not pillow: raise CommandError("No pillow found with name: {}".format(pillow_name)) checkpoint = pillow.checkpoint store = HistoricalPillowCheckpoint.get_historical_max(checkpoint.checkpoint_id) if not store: print("No new sequence exists for that pillow. You'll have to do it manually.") exit() old_seq = pillow.get_last_checkpoint_sequence() new_seq = store.seq confirm("\nReset checkpoint for '{}' pillow from:\n\n{}\n\nto\n\n{}\n\n".format( pillow_name, old_seq, new_seq )) checkpoint.update_to(new_seq) print("Checkpoint updated")
def create_historical_checkpoints(): today = date.today() thirty_days_ago = today - timedelta(days=30) HistoricalPillowCheckpoint.create_pillow_checkpoint_snapshots() HistoricalPillowCheckpoint.objects.filter( date_updated__lt=thirty_days_ago).delete()
def create_historical_checkpoints(): today = date.today() thirty_days_ago = today - timedelta(days=30) HistoricalPillowCheckpoint.create_pillow_checkpoint_snapshots() HistoricalPillowCheckpoint.objects.filter(date_updated__lt=thirty_days_ago).delete()