Welcome back. Okay.
We should be able to run the app and delete old timing records.
Before you do that, to test that deletion works properly,
I suggest pulling back a copy of the database.
You can then run queries on the copy
to check which record you'd expect to be deleted.
It's important to make sure your code is only deleting
what the user asked for.
I won't do it on the video, it's just more of the things we've already covered
and it would make the video too long.
But make sure you do test your code carefully
and be sure it's really doing what you expect it to do.
Okay. Run the app and go into reports.
When I created the code to generate the random timings data,
I set the years to 2018 and 2019.
That means there should be a load of records in 2018.
Changing the year in the NewDatePicker's a bit less obvious than the old one,
but you can tap the date at the top to change it.
I'll select 2018,
then change the date to the 29th of March,
then tap okay.
When displaying a week,
we should see records from the 25th of March,
which was a Sunday to the 31st of March,
the following Saturday.
If your emulator is set to a different locale,
your week may start on Monday instead.
I'll choose the 29th of March as the date to delete up to.
If you don't have any timings for that date,
choose a date that does have records.
From the overflow menu, the three dots on the right,
choose delete old timings.
That launches the DatePicker.
And notice, the date's automatically set
to the 29th of March 2018.
We made sure to preserve the date that the user last selected
so that things behave as they'd expect.
Tap okay and we get the confirmation dialog.
I'll test cancel first.
Our records are still there so that's good.
Just to be sure, tap the 1 icon to display a single day,
then tap the 7 to get back to a week.
The database is re-queried each time,
so we know the records are still in the database.
Tap delete old timings option again
and tap okay again.
This time, I'll confirm the deletion.
All the records before the 29th of March 2018
should have been deleted.
Records for the 29th of March should still be present.
We've told the user that they're deleting up to the date they choose,
not including it.
The display hasn't updated though,
and we can still see the same records
until I tap the one button then the 7 to re-query the database.
Filter the report to use an earlier date,
and there shouldn't be any records displayed.
Deletion is working but the report isn't getting updated.
Compare the task time of ViewModel class with this one
to work out what we haven't done in this DurationsViewModel class.
We'll fix the problem in the next video. See you there.