Adapt lifecycles artiste with translation

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-05-14 23:40:45 +04:00
parent d16ecc0eed
commit 0a310cf504
@@ -8,8 +8,8 @@
const slugify = require('slugify')
const jwennTeksEpiId = async data => {
const teks = await strapi.db.query('api::parole.parole').find({id_in: data})
return teks
const paroles = await strapi.db.query('api::parole.parole').find({id_in: data})
return paroles
}
const jwennAwtisEpiId = async id => {
@@ -40,14 +40,14 @@ module.exports = {
if (artiste.paroles && artiste.paroles.length >= 1) {
const paroles = await jwennTeksEpiId(artiste.paroles)
Promise.all(paroles.map(async t => {
const {id, tit, slug, artiste} = t
const {id, titre, slug, artiste} = t
const alias = artiste.map(a => a.alias).join('-')
const slugUpdated = slugify(`${alias}-${tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
const slugUpdated = slugify(`${alias}-${titre}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
if (slug !== slugUpdated) {
await strapi.query('paroles').update(
{id},
{slug: slugUpdated}
)
await strapi.db.query('api::parole.parole').update({
where: {id, slug: slugUpdated}
})
}
}))
}