Fix how keys are stored for luigi overnight/backfill tasks
This commit is contained in:
parent
d4801f58e3
commit
7f0305fb7a
|
@ -29,6 +29,10 @@
|
||||||
<!-- sortable> -->
|
<!-- sortable> -->
|
||||||
<!-- {{ props.row.key }} -->
|
<!-- {{ props.row.key }} -->
|
||||||
<!-- </b-table-column> -->
|
<!-- </b-table-column> -->
|
||||||
|
<b-table-column field="key"
|
||||||
|
label="Key">
|
||||||
|
{{ props.row.key }}
|
||||||
|
</b-table-column>
|
||||||
<b-table-column field="description"
|
<b-table-column field="description"
|
||||||
label="Description">
|
label="Description">
|
||||||
{{ props.row.description }}
|
{{ props.row.description }}
|
||||||
|
@ -63,11 +67,12 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
<!-- <b-field label="Key"> -->
|
<b-field label="Key"
|
||||||
<!-- <b-input v-model.trim="overnightTaskKey" -->
|
:type="overnightTaskKey ? null : 'is-danger'">
|
||||||
<!-- ref="overnightTaskKey"> -->
|
<b-input v-model.trim="overnightTaskKey"
|
||||||
<!-- </b-input> -->
|
ref="overnightTaskKey">
|
||||||
<!-- </b-field> -->
|
</b-input>
|
||||||
|
</b-field>
|
||||||
<b-field label="Description"
|
<b-field label="Description"
|
||||||
:type="overnightTaskDescription ? null : 'is-danger'">
|
:type="overnightTaskDescription ? null : 'is-danger'">
|
||||||
<b-input v-model.trim="overnightTaskDescription"
|
<b-input v-model.trim="overnightTaskDescription"
|
||||||
|
@ -91,7 +96,7 @@
|
||||||
icon-pack="fas"
|
icon-pack="fas"
|
||||||
icon-left="save"
|
icon-left="save"
|
||||||
@click="overnightTaskSave()"
|
@click="overnightTaskSave()"
|
||||||
:disabled="!overnightTaskDescription || !overnightTaskScript">
|
:disabled="!overnightTaskKey || !overnightTaskDescription || !overnightTaskScript">
|
||||||
Save
|
Save
|
||||||
</b-button>
|
</b-button>
|
||||||
<b-button @click="overnightTaskShowDialog = false">
|
<b-button @click="overnightTaskShowDialog = false">
|
||||||
|
@ -122,6 +127,10 @@
|
||||||
|
|
||||||
<b-table :data="backfillTasks">
|
<b-table :data="backfillTasks">
|
||||||
<template slot-scope="props">
|
<template slot-scope="props">
|
||||||
|
<b-table-column field="key"
|
||||||
|
label="Key">
|
||||||
|
{{ props.row.key }}
|
||||||
|
</b-table-column>
|
||||||
<b-table-column field="description"
|
<b-table-column field="description"
|
||||||
label="Description">
|
label="Description">
|
||||||
{{ props.row.description }}
|
{{ props.row.description }}
|
||||||
|
@ -164,6 +173,12 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
|
<b-field label="Key"
|
||||||
|
:type="backfillTaskKey ? null : 'is-danger'">
|
||||||
|
<b-input v-model.trim="backfillTaskKey"
|
||||||
|
ref="backfillTaskKey">
|
||||||
|
</b-input>
|
||||||
|
</b-field>
|
||||||
<b-field label="Description"
|
<b-field label="Description"
|
||||||
:type="backfillTaskDescription ? null : 'is-danger'">
|
:type="backfillTaskDescription ? null : 'is-danger'">
|
||||||
<b-input v-model.trim="backfillTaskDescription"
|
<b-input v-model.trim="backfillTaskDescription"
|
||||||
|
@ -199,7 +214,7 @@
|
||||||
icon-pack="fas"
|
icon-pack="fas"
|
||||||
icon-left="save"
|
icon-left="save"
|
||||||
@click="backfillTaskSave()"
|
@click="backfillTaskSave()"
|
||||||
:disabled="!backfillTaskDescription || !backfillTaskScript">
|
:disabled="!backfillTaskKey || !backfillTaskDescription || !backfillTaskScript">
|
||||||
Save
|
Save
|
||||||
</b-button>
|
</b-button>
|
||||||
<b-button @click="backfillTaskShowDialog = false">
|
<b-button @click="backfillTaskShowDialog = false">
|
||||||
|
@ -259,14 +274,14 @@
|
||||||
ThisPageData.overnightTaskNotes = null
|
ThisPageData.overnightTaskNotes = null
|
||||||
|
|
||||||
ThisPage.methods.overnightTaskCreate = function() {
|
ThisPage.methods.overnightTaskCreate = function() {
|
||||||
this.overnightTask = {key: null}
|
this.overnightTask = {key: null, isNew: true}
|
||||||
this.overnightTaskKey = null
|
this.overnightTaskKey = null
|
||||||
this.overnightTaskDescription = null
|
this.overnightTaskDescription = null
|
||||||
this.overnightTaskScript = null
|
this.overnightTaskScript = null
|
||||||
this.overnightTaskNotes = null
|
this.overnightTaskNotes = null
|
||||||
this.overnightTaskShowDialog = true
|
this.overnightTaskShowDialog = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.overnightTaskDescription.focus()
|
this.$refs.overnightTaskKey.focus()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,13 +295,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisPage.methods.overnightTaskSave = function() {
|
ThisPage.methods.overnightTaskSave = function() {
|
||||||
|
this.overnightTask.key = this.overnightTaskKey
|
||||||
this.overnightTask.description = this.overnightTaskDescription
|
this.overnightTask.description = this.overnightTaskDescription
|
||||||
this.overnightTask.script = this.overnightTaskScript
|
this.overnightTask.script = this.overnightTaskScript
|
||||||
this.overnightTask.notes = this.overnightTaskNotes
|
this.overnightTask.notes = this.overnightTaskNotes
|
||||||
|
|
||||||
if (!this.overnightTask.key) {
|
if (this.overnightTask.isNew) {
|
||||||
this.overnightTask.key = `_new_${'$'}{++this.overnightTaskCounter}`
|
|
||||||
this.overnightTasks.push(this.overnightTask)
|
this.overnightTasks.push(this.overnightTask)
|
||||||
|
this.overnightTask.isNew = false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.overnightTaskShowDialog = false
|
this.overnightTaskShowDialog = false
|
||||||
|
@ -313,7 +329,8 @@
|
||||||
ThisPageData.backfillTaskNotes = null
|
ThisPageData.backfillTaskNotes = null
|
||||||
|
|
||||||
ThisPage.methods.backfillTaskCreate = function() {
|
ThisPage.methods.backfillTaskCreate = function() {
|
||||||
this.backfillTask = {key: null}
|
this.backfillTask = {key: null, isNew: true}
|
||||||
|
this.backfillTaskKey = null
|
||||||
this.backfillTaskDescription = null
|
this.backfillTaskDescription = null
|
||||||
this.backfillTaskScript = null
|
this.backfillTaskScript = null
|
||||||
this.backfillTaskForward = false
|
this.backfillTaskForward = false
|
||||||
|
@ -321,12 +338,13 @@
|
||||||
this.backfillTaskNotes = null
|
this.backfillTaskNotes = null
|
||||||
this.backfillTaskShowDialog = true
|
this.backfillTaskShowDialog = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.backfillTaskDescription.focus()
|
this.$refs.backfillTaskKey.focus()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisPage.methods.backfillTaskEdit = function(task) {
|
ThisPage.methods.backfillTaskEdit = function(task) {
|
||||||
this.backfillTask = task
|
this.backfillTask = task
|
||||||
|
this.backfillTaskKey = task.key
|
||||||
this.backfillTaskDescription = task.description
|
this.backfillTaskDescription = task.description
|
||||||
this.backfillTaskScript = task.script
|
this.backfillTaskScript = task.script
|
||||||
this.backfillTaskForward = task.forward
|
this.backfillTaskForward = task.forward
|
||||||
|
@ -344,15 +362,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
ThisPage.methods.backfillTaskSave = function() {
|
ThisPage.methods.backfillTaskSave = function() {
|
||||||
|
this.backfillTask.key = this.backfillTaskKey
|
||||||
this.backfillTask.description = this.backfillTaskDescription
|
this.backfillTask.description = this.backfillTaskDescription
|
||||||
this.backfillTask.script = this.backfillTaskScript
|
this.backfillTask.script = this.backfillTaskScript
|
||||||
this.backfillTask.forward = this.backfillTaskForward
|
this.backfillTask.forward = this.backfillTaskForward
|
||||||
this.backfillTask.target_date = this.backfillTaskTargetDate
|
this.backfillTask.target_date = this.backfillTaskTargetDate
|
||||||
this.backfillTask.notes = this.backfillTaskNotes
|
this.backfillTask.notes = this.backfillTaskNotes
|
||||||
|
|
||||||
if (!this.backfillTask.key) {
|
if (this.backfillTask.isNew) {
|
||||||
this.backfillTask.key = `_new_${'$'}{++this.backfillTaskCounter}`
|
|
||||||
this.backfillTasks.push(this.backfillTask)
|
this.backfillTasks.push(this.backfillTask)
|
||||||
|
this.backfillTask.isNew = false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.backfillTaskShowDialog = false
|
this.backfillTaskShowDialog = false
|
||||||
|
|
|
@ -166,56 +166,39 @@ class LuigiTaskView(MasterView):
|
||||||
# overnight tasks
|
# overnight tasks
|
||||||
keys = []
|
keys = []
|
||||||
for task in json.loads(data['overnight_tasks']):
|
for task in json.loads(data['overnight_tasks']):
|
||||||
|
|
||||||
key = task['key']
|
key = task['key']
|
||||||
if key.startswith('_new_'):
|
|
||||||
key = app.make_uuid()
|
|
||||||
|
|
||||||
key = task['key']
|
|
||||||
if key.startswith('_new_'):
|
|
||||||
cmd = shlex.split(task['script'])
|
|
||||||
script = os.path.basename(cmd[0])
|
|
||||||
root, ext = os.path.splitext(script)
|
|
||||||
key = re.sub(r'\s+', '-', root)
|
|
||||||
|
|
||||||
keys.append(key)
|
keys.append(key)
|
||||||
settings.extend([
|
settings.extend([
|
||||||
{'name': 'rattail.luigi.overnight.{}.description'.format(key),
|
{'name': 'rattail.luigi.overnight.task.{}.description'.format(key),
|
||||||
'value': task['description']},
|
'value': task['description']},
|
||||||
{'name': 'rattail.luigi.overnight.{}.script'.format(key),
|
{'name': 'rattail.luigi.overnight.task.{}.script'.format(key),
|
||||||
'value': task['script']},
|
'value': task['script']},
|
||||||
{'name': 'rattail.luigi.overnight.{}.notes'.format(key),
|
{'name': 'rattail.luigi.overnight.task.{}.notes'.format(key),
|
||||||
'value': task['notes']},
|
'value': task['notes']},
|
||||||
])
|
])
|
||||||
if keys:
|
if keys:
|
||||||
settings.append({'name': 'rattail.luigi.overnight_tasks',
|
settings.append({'name': 'rattail.luigi.overnight.tasks',
|
||||||
'value': ', '.join(keys)})
|
'value': ', '.join(keys)})
|
||||||
|
|
||||||
# backfill tasks
|
# backfill tasks
|
||||||
keys = []
|
keys = []
|
||||||
for task in json.loads(data['backfill_tasks']):
|
for task in json.loads(data['backfill_tasks']):
|
||||||
|
|
||||||
key = task['key']
|
key = task['key']
|
||||||
if key.startswith('_new_'):
|
|
||||||
script = os.path.basename(task['script'])
|
|
||||||
root, ext = os.path.splitext(script)
|
|
||||||
key = re.sub(r'\s+', '-', root)
|
|
||||||
|
|
||||||
keys.append(key)
|
keys.append(key)
|
||||||
settings.extend([
|
settings.extend([
|
||||||
{'name': 'rattail.luigi.backfill.{}.description'.format(key),
|
{'name': 'rattail.luigi.backfill.task.{}.description'.format(key),
|
||||||
'value': task['description']},
|
'value': task['description']},
|
||||||
{'name': 'rattail.luigi.backfill.{}.script'.format(key),
|
{'name': 'rattail.luigi.backfill.task.{}.script'.format(key),
|
||||||
'value': task['script']},
|
'value': task['script']},
|
||||||
{'name': 'rattail.luigi.backfill.{}.forward'.format(key),
|
{'name': 'rattail.luigi.backfill.task.{}.forward'.format(key),
|
||||||
'value': 'true' if task['forward'] else 'false'},
|
'value': 'true' if task['forward'] else 'false'},
|
||||||
{'name': 'rattail.luigi.backfill.{}.notes'.format(key),
|
{'name': 'rattail.luigi.backfill.task.{}.notes'.format(key),
|
||||||
'value': task['notes']},
|
'value': task['notes']},
|
||||||
{'name': 'rattail.luigi.backfill.{}.target_date'.format(key),
|
{'name': 'rattail.luigi.backfill.task.{}.target_date'.format(key),
|
||||||
'value': six.text_type(task['target_date'])},
|
'value': six.text_type(task['target_date'])},
|
||||||
])
|
])
|
||||||
if keys:
|
if keys:
|
||||||
settings.append({'name': 'rattail.luigi.backfill_tasks',
|
settings.append({'name': 'rattail.luigi.backfill.tasks',
|
||||||
'value': ', '.join(keys)})
|
'value': ', '.join(keys)})
|
||||||
|
|
||||||
return settings
|
return settings
|
||||||
|
@ -228,15 +211,25 @@ class LuigiTaskView(MasterView):
|
||||||
|
|
||||||
to_delete = session.query(model.Setting)\
|
to_delete = session.query(model.Setting)\
|
||||||
.filter(sa.or_(
|
.filter(sa.or_(
|
||||||
|
model.Setting.name == 'rattail.luigi.backfill.tasks',
|
||||||
model.Setting.name == 'rattail.luigi.backfill_tasks',
|
model.Setting.name == 'rattail.luigi.backfill_tasks',
|
||||||
|
model.Setting.name.like('rattail.luigi.backfill.task.%.description'),
|
||||||
model.Setting.name.like('rattail.luigi.backfill.%.description'),
|
model.Setting.name.like('rattail.luigi.backfill.%.description'),
|
||||||
|
model.Setting.name.like('rattail.luigi.backfill.task.%.forward'),
|
||||||
model.Setting.name.like('rattail.luigi.backfill.%.forward'),
|
model.Setting.name.like('rattail.luigi.backfill.%.forward'),
|
||||||
|
model.Setting.name.like('rattail.luigi.backfill.task.%.notes'),
|
||||||
model.Setting.name.like('rattail.luigi.backfill.%.notes'),
|
model.Setting.name.like('rattail.luigi.backfill.%.notes'),
|
||||||
|
model.Setting.name.like('rattail.luigi.backfill.task.%.script'),
|
||||||
model.Setting.name.like('rattail.luigi.backfill.%.script'),
|
model.Setting.name.like('rattail.luigi.backfill.%.script'),
|
||||||
|
model.Setting.name.like('rattail.luigi.backfill.task.%.target_date'),
|
||||||
model.Setting.name.like('rattail.luigi.backfill.%.target_date'),
|
model.Setting.name.like('rattail.luigi.backfill.%.target_date'),
|
||||||
|
model.Setting.name == 'rattail.luigi.overnight.tasks',
|
||||||
model.Setting.name == 'rattail.luigi.overnight_tasks',
|
model.Setting.name == 'rattail.luigi.overnight_tasks',
|
||||||
|
model.Setting.name.like('rattail.luigi.overnight.task.%.description'),
|
||||||
model.Setting.name.like('rattail.luigi.overnight.%.description'),
|
model.Setting.name.like('rattail.luigi.overnight.%.description'),
|
||||||
|
model.Setting.name.like('rattail.luigi.overnight.task.%.notes'),
|
||||||
model.Setting.name.like('rattail.luigi.overnight.%.notes'),
|
model.Setting.name.like('rattail.luigi.overnight.%.notes'),
|
||||||
|
model.Setting.name.like('rattail.luigi.overnight.task.%.script'),
|
||||||
model.Setting.name.like('rattail.luigi.overnight.%.script')))\
|
model.Setting.name.like('rattail.luigi.overnight.%.script')))\
|
||||||
.all()
|
.all()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue