- Shipped
- August 9, 2026 at 6:21 PM UTC
- Author
- Kamo
- Commit
- e508de5
Billing was per imgs record, so an organization that uploaded the same file five times was charged five times. The owner's rule is one charge per distinct file per organization: Kamo still stores the file once system-wide, each organization holding it is still counted, and re-uploading something you already have is not a new charge. Imaging figures now come from one pass per organization that collapses records to distinct files. Measured on production for KamoCRM: 52 live records become 28 chargeable files, 6,886,309,250 bytes become 5,441,174,177. A file held under two associations is counted in exactly one — the lowest-ordinal association it appears under — because counting it in both would bill it twice. Two production files are in that position, and with this rule the categories partition the organization's files and sum exactly to its total. Period figures key on when the organization FIRST held a file, so re-uploading something it already had is not a new charge in a later period. Generated previews are keyed by file for the same reason, and trashing one copy of a file held five times frees nothing. imagingUsage() serves current, lifetime and added from a single pass, because every imaging domain needs the same grouping and computing it per domain ran the query a dozen times for one summary.