Fix processing Oban job queue and Oban retries settings

This commit is contained in:
Angelina Filippova 2019-12-22 03:46:06 +03:00
parent ec2f562356
commit 222697d048
3 changed files with 13 additions and 12 deletions

View file

@ -12,7 +12,7 @@ export const parseTuples = (tuples, key) => {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, mascot) => { accum[item.tuple[0]] = item.tuple[1].reduce((acc, mascot) => {
return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] return [...acc, { [mascot.tuple[0]]: { ...mascot.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}, []) }, [])
} else if (item.tuple[0] === ':groups' || item.tuple[0] === ':replace') { } else if (item.tuple[0] === ':groups' || item.tuple[0] === ':replace' || item.tuple[0] === ':retries') {
accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => {
return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}]
}, []) }, [])
@ -91,10 +91,9 @@ const parseProxyUrl = value => {
} }
export const partialUpdate = (group, key) => { export const partialUpdate = (group, key) => {
if ((group === ':pleroma' && key === ':ecto_repos') || if ((group === ':pleroma' && key === 'Oban') ||
(group === ':mime' && key === ':types') || (group === ':mime' && key === ':types') ||
(group === ':auto_linker' && key === ':opts') || (group === ':auto_linker' && key === ':opts')) {
(group === ':swarm' && key === ':node_blacklist')) {
return false return false
} }
return true return true
@ -129,7 +128,7 @@ const wrapValues = (settings, currentState) => {
return Object.keys(settings).map(setting => { return Object.keys(settings).map(setting => {
const [type, value] = Array.isArray(settings[setting]) ? settings[setting] : ['', settings[setting]] const [type, value] = Array.isArray(settings[setting]) ? settings[setting] : ['', settings[setting]]
if (type === 'keyword' || type.includes('keyword') || setting === ':replace') { if (type === 'keyword' || type.includes('keyword') || setting === ':replace') {
return { 'tuple': [setting, wrapValues(value)] } return { 'tuple': [setting, wrapValues(value, currentState)] }
} else if (type === 'atom' && value.length > 0) { } else if (type === 'atom' && value.length > 0) {
return { 'tuple': [setting, `:${value}`] } return { 'tuple': [setting, `:${value}`] }
} else if (type.includes('tuple') && Array.isArray(value)) { } else if (type.includes('tuple') && Array.isArray(value)) {
@ -149,7 +148,7 @@ const wrapValues = (settings, currentState) => {
const ip = value.split('.').map(s => parseInt(s, 10)) const ip = value.split('.').map(s => parseInt(s, 10))
return { 'tuple': [setting, { 'tuple': ip }] } return { 'tuple': [setting, { 'tuple': ip }] }
} else if (setting === ':ssl_options') { } else if (setting === ':ssl_options') {
return { 'tuple': [setting, wrapValues(value)] } return { 'tuple': [setting, wrapValues(value, currentState)] }
} else { } else {
return { 'tuple': [setting, value] } return { 'tuple': [setting, value] }
} }

View file

@ -75,7 +75,10 @@ const settings = {
acc[group] = Object.keys(state.updatedSettings[group]).reduce((acc, key) => { acc[group] = Object.keys(state.updatedSettings[group]).reduce((acc, key) => {
if (!partialUpdate(group, key)) { if (!partialUpdate(group, key)) {
const updated = Object.keys(state.settings[group][key]).reduce((acc, settingName) => { const updated = Object.keys(state.settings[group][key]).reduce((acc, settingName) => {
acc[settingName] = ['', state.settings[group][key][settingName]] const settingType = state.description
.find(element => element.group === group && element.key === key).children
.find(child => child.key === settingName).type
acc[settingName] = [settingType, state.settings[group][key][settingName]]
return acc return acc
}, {}) }, {})
acc[key] = updated acc[key] = updated
@ -86,7 +89,6 @@ const settings = {
}, {}) }, {})
return acc return acc
}, {}) }, {})
const configs = Object.keys(updatedData).reduce((acc, group) => { const configs = Object.keys(updatedData).reduce((acc, group) => {
return [...acc, ...wrapUpdatedSettings(group, updatedData[group], state.settings)] return [...acc, ...wrapUpdatedSettings(group, updatedData[group], state.settings)]
}, []) }, [])

View file

@ -58,12 +58,12 @@ export default {
methods: { methods: {
addRowToEditableKeyword() { addRowToEditableKeyword() {
const updatedValue = [...this.data, { '': { value: '', id: this.generateID() }}] const updatedValue = [...this.data, { '': { value: '', id: this.generateID() }}]
this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key) this.updateSetting(updatedValue, this.settingGroup.group, this.settingGroup.key, this.setting.key, this.setting.type)
}, },
deleteEditableKeywordRow(element) { deleteEditableKeywordRow(element) {
const deletedId = this.getId(element) const deletedId = this.getId(element)
const filteredValues = this.data.filter(element => Object.values(element)[0].id !== deletedId) const filteredValues = this.data.filter(element => Object.values(element)[0].id !== deletedId)
this.updateSetting(filteredValues, this.settingGroup.group, this.settingGroup.key, this.setting.key) this.updateSetting(filteredValues, this.settingGroup.group, this.settingGroup.key, this.setting.key, this.setting.type)
}, },
generateID() { generateID() {
return `f${(~~(Math.random() * 1e8)).toString(16)}` return `f${(~~(Math.random() * 1e8)).toString(16)}`
@ -95,7 +95,7 @@ export default {
updateSetting(value, group, key, input, type) { updateSetting(value, group, key, input, type) {
const updatedSettings = type !== 'map' const updatedSettings = type !== 'map'
? value.reduce((acc, element) => { ? value.reduce((acc, element) => {
return { ...acc, [Object.keys(element)[0]]: [['list', 'string'], Object.values(element)[0].value] } return { ...acc, [Object.keys(element)[0]]: [['list'], Object.values(element)[0].value] }
}, {}) }, {})
: value.reduce((acc, element) => { : value.reduce((acc, element) => {
return { ...acc, [Object.keys(element)[0]]: Object.values(element)[0].value } return { ...acc, [Object.keys(element)[0]]: Object.values(element)[0].value }