Design number invetory and search system

Should support most queries we support now.

Fallback to bandwidth search in some cases? Or do both and mix?

My initial input is that I think with the small amount of stock we’re likely to keep we can probably do city and province search by geocoding then looking up nearby area codes then prefix search the stock or similar. We have a table to look up nearby area codes already we use for city search fallback.

Assuming a postgres table, maybe something like

tel TEXT NOT NULL
premium_price NUMERIC NOT NULL DEFAULT 0
locality TEXT

is this enough? We only need the locality label if we want to continue to display the city/location text next to numbers in search results, which there was some recent discussion about maybe stopping? It’s probably even less helpful with this new low stock world.

Searches we need to support:

area code: select * from tel_inventory where tel like '+1' || areacode;

zip or postal code: we actually don’t support postal code in canada now anyway, so maybe we can skip it

state or province code: We could geolocate and look up area codes, but that’s actually maybe not helpful since searching ON might show numbers outside of ON that way, it’s not scoped enough and the search is broad enough we probably don’t want to show “nearby”. Easy solution here is to either add a province code column to the inventory table, or add it to the area_codes table (which currently has only country) then search for all area codes in a province.

six or seven digit prefix: same as area code just longer prefix, easy

city, province code: this search currently falls back to the nearby area code search if stock in too low. In this new world, stock will always be low so maybe we should just always do that. Geocode city, province then get the top 3 closest area codes in the country and search those.

vanity pattern: will need alpha to digit conversion for this, but then it’s just a substring search I think? So shouldn’t be too hard to do with like similar to prefixes.

Do we want to be able to directly recycle numbers from our own customers and have an available_after column or is it easiest to just cancel numbers on expiry just like we always have and let the stock system re-backorder. Cost to us should be the same either way.

Probably should have a column with what bandwidth account id the number is in, so we can sell out of 2nd acct etc.

Also needs a column for price