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 slugify = require('slugify')
const jwennTeksEpiId = async data => { const jwennTeksEpiId = async data => {
const teks = await strapi.db.query('api::parole.parole').find({id_in: data}) const paroles = await strapi.db.query('api::parole.parole').find({id_in: data})
return teks return paroles
} }
const jwennAwtisEpiId = async id => { const jwennAwtisEpiId = async id => {
@@ -40,14 +40,14 @@ module.exports = {
if (artiste.paroles && artiste.paroles.length >= 1) { if (artiste.paroles && artiste.paroles.length >= 1) {
const paroles = await jwennTeksEpiId(artiste.paroles) const paroles = await jwennTeksEpiId(artiste.paroles)
Promise.all(paroles.map(async t => { 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 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) { if (slug !== slugUpdated) {
await strapi.query('paroles').update( await strapi.db.query('api::parole.parole').update({
{id}, where: {id, slug: slugUpdated}
{slug: slugUpdated} })
)
} }
})) }))
} }