codeforpdx / dwellingly-app

Application for property managers to communicate with social workers
48 stars 28 forks source link

Update `lastActive` when user signs in #832

Closed aedwardg closed 2 years ago

aedwardg commented 2 years ago

What issue is this solving?

closes #829

The front end was rendering the "Last Usage" column based on the user's lastActive status, but this field in the database was never getting updated. Since we're not using devise trackable (which would automatically update last_sign_in_at, current_sign_in_at, etc.) we need to update this value ourselves.

Note, this saves the datetime in the db in UTC time. I don't think we alter that for the front-end, so it may look off by a day if checked at certain times.

Screenshot image

Any helpful knowledge/context for the reviewer?

Is a yarn install necessary? ❌ Any special requirements to test?

Please make sure you've attempted to meet the following coding standards

If you're having trouble meeting this criteria, feel free to reach out on Slack for help!

aedwardg commented 2 years ago

@NickSchimek Open to any thoughts on if/how we want to test this.

NickSchimek commented 2 years ago

@NickSchimek Open to any thoughts on if/how we want to test this.

A rails request spec. When a property_manager signs in. We update lastActive and respond successfully with a serialized property manager. Check serialization (lastActive) is correct.

aedwardg commented 2 years ago

@NickSchimek I just tried using update_column, but rubocop doesn't like it. Should I change it back to update! ?

NickSchimek commented 2 years ago

Oh we can turn that cop off, or disable it for that one line. Your choice.

The spec looks good. Just need to remove the puts

aedwardg commented 2 years ago

Oh we can turn that cop off, or disable it for that one line. Your choice.

I decided to only disable it for that line. I think in the long run, it's better to have it, especially if people less familiar with Rails contribute and see update_column here.