Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/migrate images #265

Merged
merged 51 commits into from
Dec 22, 2020
Merged

Feature/migrate images #265

merged 51 commits into from
Dec 22, 2020

Conversation

rlskoeser
Copy link
Contributor

see #248

@codecov-io
Copy link

codecov-io commented Dec 21, 2020

Codecov Report

Merging #265 (4328ebc) into develop (6bbb0f4) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff            @@
##           develop     #265   +/-   ##
========================================
  Coverage    97.68%   97.68%           
========================================
  Files           99       99           
  Lines         3150     3150           
========================================
  Hits          3077     3077           
  Misses          73       73           

Copy link
Contributor

@thatbudakguy thatbudakguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything looks good, just a few questions.

Comment on lines +245 to +248
coll = Collection.objects.filter(name=name).first()
# otherwise, create it
if not coll:
coll = Collection(name=name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be a get_or_create()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I tried that — doesn't work because it has to be added to the parent to set the hierarchy properly

Comment on lines 262 to 263
# delete all images prior to run (clear out past migration attempts)
Image.objects.all().delete()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also do this for collections?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe? I have some extraneous collections right now that I think the current version of the script wouldn't create but older versions did; but once the script is stable I don't think it matters or gets us much. (I'm open to it, LMK)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think for consistency let's do it. gives me peace of mind to know that everything is being wiped, haha

Comment on lines +275 to +278
# NOTE: leaving this here in case we want to handle
# documents the same way
if extension in ['.pdf', '.svg', '.docx']:
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, this is handy - thx for the note

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah — thought about filtering them out when I filter out the duplicates, but wasn't sure yet how we'll handle the files

# check files with the same name in multiple locations
for key, val in unique_filenames.items():
if len(val) > 1:
samefile = filecmp.cmp(val[0], val[1], shallow=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only compares the first two, right?

Comment on lines +330 to +341
# if not all the same, identify the largest
# (all are variant/cropped versions of the same image)
else:
largest_file = None
largest_size = 0
for filepath in val:
size = os.stat(filepath).st_size
if size > largest_size:
largest_size = size
largest_file = filepath

extra_copies = [f for f in val if f != largest_file]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we ever end up with situations where there are totally unrelated images with the same name (e.g. Untitled-1 or Upload or something generic)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nvm - I see your report on the issue that confirms this isn't a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right — here's the list #248 (comment)

Comment on lines +17 to +18
L,M @1x W: 2560px H: 680px, @2x W: 5120px H: 1360px
S @1x W: 736px H: 320px, @2x W: 1472px H: 640px
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw the L/M 2x seems huge; I don't think we ever want to be serving stuff larger than 2500px. but fine for now; we can always revisit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are Xinyi's guidelines, maybe they need to be revisited. I agree it's huge (and I think what we've always been serving, even for mobile — although I guess before we just served out whatever we had; will wagtail make images larger?). This is why I asked you about the background image and different sizes.

Do you want to make a new issue for addressing this and add it to 3.1 ? It would be a good improvement to the site.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #266 and added to 3.1

@rlskoeser rlskoeser merged commit 8d7c85b into develop Dec 22, 2020
@rlskoeser rlskoeser deleted the feature/migrate-images branch December 22, 2020 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants