Attached.Originals.Stats (Attached v0.1.0)

Copy Markdown View Source

Aggregate statistics over attached_originals.

Intended for dashboards and scripts. If you need raw counts with custom scopes, use Attached.Originals.count/1 with a :query hook instead.

Summary

Functions

Original counts grouped by major MIME type, sorted by count descending.

Per-group original statistics as [%{owner_table, owner_field, original_count, total_bytes}], sorted by count descending.

Original counts and size aggregates grouped by storage backend.

Top-level summary of original storage.

Functions

by_content_type()

Original counts grouped by major MIME type, sorted by count descending.

[
  %{type: "image", record_count: 9_102},
  %{type: "video", record_count: 2_841},
  %{type: "application", record_count: 510}
]

Groups by the major type (the part before the / in the content type), so image/png, image/jpeg, and image/webp all map to "image".

by_owner_group()

Per-group original statistics as [%{owner_table, owner_field, original_count, total_bytes}], sorted by count descending.

by_storage_backend()

Original counts and size aggregates grouped by storage backend.

[
  %{
    storage_backend: "Attached.StorageBackends.S3",
    record_count: 11_203,
    total_bytes: 9_700_000_000,
    avg_bytes: 865_848,
    max_bytes: 524_288_000
  }
]

overview()

Top-level summary of original storage.

%{record_count: 12_453, total_bytes: 9_812_441_103}