Given a Number, looking to create a specific collection [fun challenge]

Main goal is to create a collection (or array, though the language is somewhat confusing with make) which mirrors the following:

Screenshot 2024-03-08 at 4.16.04 PM

Specifically the “ComptersComplete” collection

The only input is the number of chapters (in the above example 10 is the input)… but that value is variable.

I’ve been playing with using a repeater and text aggregator but no luck…

I feel like i’m at the edge of sorting this thing out, but out of ideas. Any help would be greatly appreciated!

The very end goal is to create a firestore mapped filed with these values, but that part should be fairly simple once i have the collection/array structured correclty.

This is already a collection.

You cannot make a similar structure in an array because array keys do not have names, and are numbered 1-12 (including intro and conclusion).

So without knowing what you are trying to do after this, I cannot provide further advice.

2 Likes

Sorry Sam, to clarify - that is the final output I’m looking for (it’s a firestore document of course). I built that collection to show the end result i’m looking for

Basically I’m looking to dynamically generate the ChaptersComplete in make in a similar structure to the one pictured with the challenge being that I only have one input (the number of chapters, in this case 10).

I guess a better way to put it is I’m hoping to create the following JSON dynamically using just Make functionality…

{
  "fields": {
    "ChaptersComplete": {
      "Chapter_4": "incomplete",
      "Chapter_1": "incomplete",
      "Chapter_8": "incomplete",
      "Chapter_2": "incomplete",
      "Chapter_10": "incomplete",
      "Chapter_6": "incomplete",
      "Chapter_5": "incomplete",
      "Chapter_9": "incomplete",
      "conclusion": "incomplete",
      "Chapter_7": "incomplete",
      "introduction": "incomplete",
      "Chapter_3": "incomplete"
    }
  }
}

The only input I would have is the num. of chapters, and I’m thinking a combination of text aggregation module and repeater could accomplish the goal.

I’ve attached a blueprint based on some attempts I’ve made… any help would be delightful, but don’t want to eat up too many ops :stuck_out_tongue: hah

example blueprint for chapter structure to generate blueprint.json (40.2 KB)

1 Like

I think you are close. Just that the text aggregator shouldn’t contain any brackets.

Screenshot_2024-03-10_120354

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.

  3. Click on each imported module and save it. You may need to remap some variables.

Modules JSON Export

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 1,
                    "module": "builtin:BasicRepeater",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "start": "1",
                        "repeats": "10",
                        "step": "1"
                    },
                    "metadata": {
                        "designer": {
                            "x": 0,
                            "y": 0,
                            "name": "Build chapters"
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "start",
                                "type": "number",
                                "label": "Initial value",
                                "required": true
                            },
                            {
                                "name": "repeats",
                                "type": "number",
                                "label": "Repeats",
                                "validate": {
                                    "min": 0,
                                    "max": 10000
                                },
                                "required": true
                            },
                            {
                                "name": "step",
                                "type": "number",
                                "label": "Step",
                                "required": true
                            }
                        ]
                    }
                },
                {
                    "id": 2,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "rowSeparator": "other",
                        "otherRowSeparator": ", ",
                        "feeder": 1
                    },
                    "mapper": {
                        "value": "\"Chapter_{{1.i}}\": \"incomplete\""
                    },
                    "metadata": {
                        "designer": {
                            "x": 245,
                            "y": 0
                        },
                        "restore": {
                            "parameters": {
                                "rowSeparator": {
                                    "label": "Other"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "Build chapters [1]"
                                }
                            },
                            "flags": {
                                "groupBy": {
                                    "collapsed": true
                                },
                                "stopIfEmpty": {
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            },
                            {
                                "name": "otherRowSeparator",
                                "type": "text",
                                "label": "Separator"
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    }
                },
                {
                    "id": 3,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "{\n  \"fields\": {\n    \"ChaptersComplete\": {\n      {{2.text}},\n      \"introduction\": \"incomplete\",\n      \"conclusion\": \"incomplete\",\n    }\n  }\n}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 490,
                            "y": -5,
                            "name": "JSON",
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
3 Likes

YOU ROCK! Thank You!

2 Likes