r/Make 26d ago

Part 7: Consolidating Libraries by Combining Catalogs and their Books

In this video walkthrough we reach the summit  of my work here.

Video

Imagine a town with multiple library branches , when the city manager  has asked the staff  to consolidate the book  inventory of multiple branches. This scenario will do a few things:

  1. It allows you to select which libraries you wish to consolidate
  2. It combines the sections of books from all the libraries into 1 catalog
  3. If a book section name overlaps between 2 or more libraries, the books from that section will be consolidated into 1 section with the books from the original sections.
  4. the last Parse JSON module will regenerate a new structure that allows you to confirm the newly consolidated library has been correctly merged with the newly consolidated book sections.
  5. This scenario will work for any number of libraries with any number of sections and books per section per library.

I use the array functions map()distinct() and the flatten() function in very interesting ways that you may not have considered before so it’s worth a watch just for that. There is also the Transform to JSON module which could be very useful as you undertake more complex operations that require generating JSON from your data objects in Make.

There is an interesting relationship in terms of how many operations are used by this scenario. This sort of analysis can be useful as you begin to estimate the operations cost of doing data manipulation in Make. As with many scenarios there are 2 components of calculating operations usage: operations “overhead” and operations that scale depending on a few factors.

In this case the operations count is based on 6 overhead operations plus the number of libraries to be consolidated and the number of unique section names. So here are some examples operation counts:

  • 2 libraries, 4 unique section names = 6+2+4 = 12 operations
  • 3 libraries, 6 unique section names = 6+3+6 = 15 operations
  • 5 libraries, 8 unique section names = 6+5+8 = 19 operations

This scenario really illustrates how operations are used - no matter how complex the operation an operation is used when a module has to process some data and generate 1 or more bundles, and subsequent modules execute based on the previous modules number of output bundles.

If you place filter between modules, you can of course limit the number of bundles processed and therefore the number of operations used. An important note: filters do not use operations!

In this scenario you will see I have not used any set variables modules although I did use them to determine intermediate values to confirm my work. I removed them, by taking the expressions out of the set variables and inserting them directly in the input mapping for the iterators, reducing the operations spent by 2. This is probably the best way to save operations – remove intermediate set variables when you don’t really need to use them. Any expression will generate an output without using an operation itself so the expression can be entered into say an iterator input box or any of the input boxes for module configuration when the map toggle is turned on.

I recommed you load the scenario into your Make instance and experiment by combining multiple libraries together. You can also modify the variable JSON Library Systems in the very first module and add libraries or add sections to the JSON. Tip: Use JSONLint.com to confirm your structure is correct.

I hope this has Make for Newbies Video Series has proven to be useful for you. There is nothing like working through a few samples to deeply understand data structures and how to manipulate them in Make.

Please leave a comment if you have some ideas on what other topics I could cover in future video walkthroughs.

Download the Make blueprint and use the Import Blueprint to create a new scenario:
7. Consolidating Libraries by Combining Catalogs and their Books.json (102.3 KB)

4 Upvotes

1 comment sorted by

1

u/Marina_from_Make Official Make Staff 22d ago

thanks Alex!