Rename awtis to artistes

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-05-12 18:38:19 +04:00
parent deff277164
commit d906450f05
6 changed files with 20 additions and 2449 deletions
@@ -8,13 +8,13 @@
const slugify = require('slugify') const slugify = require('slugify')
const jwennTeksEpiId = async data => { const jwennTeksEpiId = async data => {
const teks = await strapi.query('teks').find({id_in: data}) const teks = await strapi.query('paroles').find({id_in: data})
return teks return teks
} }
const jwennAwtisEpiId = async id => { const jwennAwtisEpiId = async id => {
const awtis = await strapi.query('awtis').find({id}) const artiste = await strapi.query('artiste').find({id})
return awtis return artiste
} }
module.exports = { module.exports = {
@@ -33,16 +33,16 @@ module.exports = {
afterUpdate: async event => { afterUpdate: async event => {
let {data} = event let {data} = event
const {id} = data const {id} = data
const awtis = await jwennAwtisEpiId(id) const artiste = await jwennAwtisEpiId(id)
if (awtis.teks && awtis.teks.length >= 1) { if (artiste.teks && artiste.paroles.length >= 1) {
const teks = await jwennTeksEpiId(awtis.teks) const paroles = await jwennTeksEpiId(artiste.paroles)
Promise.all(teks.map(async t => { Promise.all(paroles.map(async t => {
const {id, tit, slug, awtis} = t const {id, tit, slug, artiste} = t
const alias = awtis.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}-${tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
if (slug !== slugUpdated) { if (slug !== slugUpdated) {
await strapi.query('teks').update( await strapi.query('paroles').update(
{id}, {id},
{slug: slugUpdated} {slug: slugUpdated}
) )
@@ -1,10 +1,10 @@
{ {
"kind": "collectionType", "kind": "collectionType",
"collectionName": "awtis", "collectionName": "artistes",
"info": { "info": {
"singularName": "awti", "singularName": "artiste",
"pluralName": "awtis", "pluralName": "artistes",
"displayName": "Awtis", "displayName": "Artistes",
"description": "" "description": ""
}, },
"options": { "options": {
@@ -30,11 +30,11 @@
"slug": { "slug": {
"type": "string" "type": "string"
}, },
"teks": { "paroles": {
"type": "relation", "type": "relation",
"relation": "manyToMany", "relation": "manyToMany",
"target": "api::tek.tek", "target": "api::parole.parole",
"inversedBy": "awtis" "inversedBy": "artistes"
}, },
"admin_user": { "admin_user": {
"type": "relation", "type": "relation",
@@ -2,4 +2,4 @@
const { createCoreController } = require('@strapi/strapi').factories; const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::awti.awti') module.exports = createCoreController('api::artiste.artiste')
@@ -2,4 +2,4 @@
const { createCoreRouter } = require('@strapi/strapi').factories; const { createCoreRouter } = require('@strapi/strapi').factories;
module.exports = createCoreRouter('api::awti.awti') module.exports = createCoreRouter('api::artiste.artiste')
@@ -2,4 +2,4 @@
const { createCoreService } = require('@strapi/strapi').factories; const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::awti.awti'); module.exports = createCoreService('api::artiste.artiste');
File diff suppressed because it is too large Load Diff