Skip to content

Intents-Array is unsorted and randomized each pull #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
KingofGnome opened this issue Dec 30, 2021 · 2 comments
Closed

Intents-Array is unsorted and randomized each pull #33

KingofGnome opened this issue Dec 30, 2021 · 2 comments

Comments

@KingofGnome
Copy link

The intents.json-file in each flow, containing an array with each intent as json, stores the intents in randomized order (completely changing the file each clone/pull).
This does not happen to any other file/array, like in the chats.json.

Theres no reason for that, especially when the intents in cognigy-ui are shown in alphabetical order.

This could be fixed by sorting the intents by name in the flow.js with something like this:

    const flowIntents = await CognigyClient.exportIntents({
        flowId: flow._id,
        localeId: locale._id,
        format: 'json',
        type: null
    });

    flowIntents.sort((a, b) => +(a.name > b.name) || -(a.name < b.name));

    fs.writeFileSync(localeDir + "/intents.json", JSON.stringify(flowIntents, undefined, 4));

However its probably better to find out why CognigyClient.exportIntents shuffles around the intents every pull and fix it there?

Motivation:
Randomized intent-files are a problem, as we're trying to create changelogs for botprojects using cognigy-cli+git and git can't handle the changes in intents if they're randomized each pull.

@petersenj
Copy link

I just created a pull request that concerns this issue - although I went the route of your suggestion and added sorting to intents, flow config, lexicon csv and endpoints config #39

@petersenj
Copy link

I now added pull request #40 that sorts lexicon data - slots and synonyms - as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants