theNewDynamic / tnd-content-generator

A Data set generator built with Mockaroo and Hugo
MIT License
0 stars 0 forks source link

Consolidate limit and iteration with limit #3

Closed regisphilibert closed 2 years ago

regisphilibert commented 2 years ago

Each mockaroo data set has 1000 entries for us to use. This means we can either create less than 1000 entries, or a multiple of 1000 using a system of iterations. (Range on mockaroo entries to create first 1000 files, range again, modify title and id with iteration number: {title}-2 to create next 1000 files and around we go...

Currently user sets limit to get less than 1000 items and iterations to get 1000, 2000, 3000, etc... entries.

Ideally we'd like the user to enter any limit (< 1000 or > 1000) and creates the exact desired number.

To do se we need to:

  1. Round up the number to isolate an iteration number (ex: 3434 gives 4 iterations, 650 gives 1 iteration)
  2. Determine a limit of files for the last iteration. (ex: 3434 means last iteration (the 4th) limit is 434, 650 means last iteration (the 1st) limit is 650

With the above we can use the same code for every use case. A code which will define $iterations and $last_iteration_limit. While ranging on iterations, it will, when on the last iteration, use first $last_iteration_limit $entries to limit the mockaroo entries.