Skip to content

Commit

Permalink
Gerando dump com comando python dumpdata em json Resolves radar-parla…
Browse files Browse the repository at this point in the history
…mentar#465

Co-authored-by: Felipe Osório <[email protected]>
Co-authored-by: Harrison Pedro <[email protected]>
  • Loading branch information
3 people committed May 16, 2018
1 parent 9e3a048 commit b9db53d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions radar_parlamentar/cron/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def do(self):
logger.info('DbDumperJob foi chamado.')
weekday = date.today().weekday()
# segunda é o zero

if weekday == 0:
dumper = DbDumper()
dumper.dump()
logger.info('DbDumperJob fazendo dump do banco.')
else:
logger.info('Hoje não é o dia. DbDumperJob só trabalha às segundas.')
Expand All @@ -115,10 +118,10 @@ class DbDumper():
# Teste de DbDumper: 1o apaga arquivo se existir, executa, verifica se arquivo foi criado
# publicar radar/base no docker hub

DUMP_FILE = "/radar/radar_parlamentar/radar_parlamentar/static/db-dump/radar.sql"
DUMP_FILE = "/radar/radar_parlamentar/radar_parlamentar/static/db-dump/radar.json"

def dump(self):
dump_command = 'pg_dump -h postgres -U radar -d radar -W --inserts -t modelagem_* -f %s' % DbDumper.DUMP_FILE
dump_command = 'python manage.py dumpdata > %s' % DbDumper.DUMP_FILE
os.system(dump_command)
#compress_command = 'bzip2 -9 -f %s' % DbDumper.DUMP_FILE
#os.system(compress_command)
Expand Down
1 change: 1 addition & 0 deletions radar_parlamentar/radar_parlamentar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@

CRON_CLASSES = [
'cron.jobs.ImportadorJob',
'cron.jobs.DbDumperJob'
]

if os.getenv('RADAR_TEST'):
Expand Down

0 comments on commit b9db53d

Please sign in to comment.