Back to Feed
article 3m read

A double-tag report reading a feed that had already merged the doubles away

Building a report to flag one product with two live package tags in the same store led to a day of fixing what it meant by the same item: an unmerged per-package feed, split rows added together, one size bucket for loose flower, selling-floor stock only, and product IDs instead of names. Unreachable stores still get skipped without a word.

Article DepthPractice

Flow

How my double-tag report changed in one day

The first version, then the five fixes. Each fix changed what the report treats as the same item.

  1. 1Merged feed

    First version read one row per product, so doubles could not show.

  2. 2Per-package feed

    New feed with one row per package, unmerged.

  3. 3Split rows

    Rows sharing a tag now add their quantities.

  4. 4Loose flower

    Sold by weight, so it shares one size.

  5. 5Selling floor

    Back-room stock no longer counts; unknown rooms count in full.

  6. 6Product ID

    Groups by ID, with the name only as a fallback.

A report I built to catch one product with two live tags in the same store first read from a feed that had already merged the doubles away.

Some products in the stores are tracked one package at a time, and each package has its own tag. One product, at one size, in one store, should have one live package at a time. Two live tags usually means a mistake when stock came in. I wanted the ordering system to find those and email a list. The report went in, and five fixes followed the same day. The report sorts rows into groups by store, product and size, and that group key is its whole idea of "the same item". Each change fixed a wrong part of that idea.

A feed that had already done the merging

My first version used an existing inventory feed. That feed combines all rows for a product into one row. Fine for counting stock. Wrong here, because once two packages are combined, their two tags look like one.

The counting code was fine. It was just looking at the wrong rows.

It groups rows by store, product and size and flags groups with two or more tags, but fed the summary, each product has just one row and so just one tag.

As far as I can tell, the first version could only flag two products that shared a name. So I added a new feed that passes back one row per package, unmerged. The report switched to it.

One tag, two rows

The old code ignored a second row with the same tag. With the new feed that is normal, because a package split across two rooms shows up twice. Now those rows add their quantities together.

Loose flower has no size

Size belongs in the key for bags of a set size. Loose flower is sold by weight, so every package has a different weight, and none could ever be flagged. Loose flower now shares one size. The check that decides "loose" reads the category text, which is fragile.

The back room doesn't count

Stock in the back room isn't for sale. The report now counts only what's in rooms named as the selling floor. If a row has no room data, it counts all of it. An extra row is easier to dismiss than a missed one.

Names that outlive their products

Grouping by display name gave false alarms from old, stale entries. The report now groups by the product's ID, and uses the name only when there's no ID.

Two holes I left in

If a store can't be reached, the report skips it without saying so. A renamed selling-floor room would also make that store look clean. Until that changes, an empty store on that report tells me nothing.

Keep reading

Pick up a connected idea or branch into a nearby one.

5 paths forward