Skip to content

Instantly share code, notes, and snippets.

@MisterDaniels
Created November 10, 2021 11:35
Show Gist options
  • Save MisterDaniels/f533100065fab6e85059006a810a0000 to your computer and use it in GitHub Desktop.
Save MisterDaniels/f533100065fab6e85059006a810a0000 to your computer and use it in GitHub Desktop.
Auryn - Corrige tamanho do arquivo da Toyformatura
#!/bin/bash
set -e
# Execute o SQL abaixo (mas troque o projeto né),
# salve o resultado como CSV separado por tabulação com o nome:
# correcaoTamanhoArquivosToy.csv
#
# Depois de feito isso, execute este script,
# pegue a saída dele (vai gerar uns SQLs de update)
# e execute no banco em produção.
# Só confere antes né!
#select convert(image_external_source.image_id, char) as id, image_external_source.source
#from image_external_source
#join image
#on image_external_source.image_id = image.cache_image_id
#and image_external_source.is_original = 1
#where image.project_id = 368884
while IFS=$'\t' read -r ID URL ; do
imageSize=$( curl -s -L -I $URL | grep "Content-Length: " | sed 's/Content-Length: //g' | sed 's/[^0-9]*//g' )
updateSQL="update image_external_source set file_size = $imageSize where is_original = 1 and image_id = $ID;"
echo $updateSQL
done < "correcaoTamanhoArquivosToy.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment