harvard-lil / perma

Indelible links
420 stars 71 forks source link

Backfill last_login from axes logs #3302

Closed rebeccacremona closed 1 year ago

rebeccacremona commented 1 year ago

Now that https://github.com/harvard-lil/perma/issues/3296 is fixed going forward, this PR fixes our data, to the extent that we can: it looks in the axes login records and finds the most recent one for each user, and puts that date into last_login. There's a gap of a few months where we just don't have data... but c'est la vie.

Run locally against ~80K records in a prod-like database, this took 1.5s... so I decided to do it cleanly as a data migration. So, if it takes a long time, that means we'll have a slower deployment than usual... but I think even if it ends up being much slower, adding a minute or two while we are in maintenance mode is perfectly fine.

I'm not sure where the prints will be visible, because this will happen as part of a Salt orchestration. @bensteinberg do you know? if you would recommend using the logger instead of printing for any reason, happy to switch.

bensteinberg commented 1 year ago

I'm not sure where the prints will be visible

I think if they are sent to stdout when we run manage.py migrate, we'll be able to see them by looking at the output of the perma-migrate state run -- and we can confirm this when we deploy to stage.

codecov[bot] commented 1 year ago

Codecov Report

Merging #3302 (5077afd) into develop (bbbec52) will decrease coverage by 0.11%. The diff coverage is n/a.

:exclamation: Current head 5077afd differs from pull request most recent head 2848433. Consider uploading reports for the commit 2848433 to get more accurate results

@@             Coverage Diff             @@
##           develop    #3302      +/-   ##
===========================================
- Coverage    73.64%   73.54%   -0.11%     
===========================================
  Files           55       55              
  Lines         6641     6641              
===========================================
- Hits          4891     4884       -7     
- Misses        1750     1757       +7     

see 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.