8
A million products
1M rowsTwo joins, a computed margin, five filters and exports, over a million rows. Every sort, filter and page runs in the database.
Filter to one category, sort by price, then export what's left as CSV or PDF.
|
ID
|
Product
|
Brand
|
Price
| Cost | Margin |
Stock
| Status |
Rating
|
|---|---|---|---|---|---|---|---|---|
| #1000000 |
Advanced Sports 1000000
FLG1000000
|
Louis
Garden
| ₹10,104 | ₹5,953 | 69.7% | 4248 | draft | 1.6 ★ |
| #999999 |
Classic Loafers 999999
FLG0999999
|
Peter
Grocery
| ₹7,008 | ₹5,811 | 20.6% | 1039 | active | 3.7 ★ |
| #999998 |
Ultra Board 999998
FLG0999998
|
Louis
Jewelry
| ₹53,832 | ₹32,327 | 66.5% | 1306 | active | 4.8 ★ |
| #999997 |
Modern Suit 999997
FLG0999997
|
Park
Clothing
| ₹11,889 | ₹7,010 | 69.6% | 4306 | draft | 3.5 ★ |
| #999996 |
Advanced Flats 999996
FLG0999996
|
HP
Electronics
| ₹4,827 | ₹3,166 | 52.5% | 2566 | active | 4.2 ★ |
| #999995 |
Essential Item 999995
FLG0999995
|
Asus
Footwear
| ₹25,230 | ₹14,905 | 69.3% | 2726 | draft | 4.9 ★ |
| #999994 |
Advanced Sandals 999994
FLG0999994
|
Peter
Home
| ₹33,005 | ₹18,456 | 78.8% | 96 | active | 3.4 ★ |
| #999993 |
Pro Figure 999993
FLG0999993
|
HP
Kitchen
| ₹86,615 | ₹47,821 | 81.1% | 2187 | active | 4.5 ★ |
| #999992 |
Advanced Accessory 999992
FLG0999992
|
Peter
Health
| ₹7,704 | ₹6,990 | 10.2% | 4984 | active | 4.5 ★ |
| #999991 |
Premium Accessory 999991
FLG0999991
|
Global
Electronics
| ₹13,438 | ₹10,466 | 28.4% | 4160 | draft | 1.5 ★ |
| #999990 |
Basic Bundle 999990
FLG0999990
|
Reebok
Electronics
| ₹34,519 | ₹28,912 | 19.4% | 2110 | active | 4.4 ★ |
| #999989 |
Elite Collection 999989
FLG0999989
|
Fastrack
Office
| ₹37,346 | ₹22,429 | 66.5% | 3111 | discontinued | 4.9 ★ |
| #999988 |
Classic Product 999988
FLG0999988
|
Louis
Electronics
| ₹67,979 | ₹34,165 | 99.0% | 2097 | active | 3.7 ★ |
| #999987 |
Advanced Bat 999987
FLG0999987
|
Nike
Office
| ₹41,567 | ₹31,357 | 32.6% | 359 | draft | 2.5 ★ |
| #999986 |
Premium Board 999986
FLG0999986
|
Global
Books
| ₹35,176 | ₹30,432 | 15.6% | 995 | active | 2.1 ★ |
| #999985 |
Pro Manual 999985
FLG0999985
|
Oppo
Electronics
| ₹50,840 | ₹36,640 | 38.8% | 4434 | active | 4.6 ★ |
| #999984 |
Basic Pack 999984
FLG0999984
|
Nike
Office
| ₹52,260 | ₹35,341 | 47.9% | 3019 | discontinued | 3.2 ★ |
| #999983 |
Basic Accessory 999983
FLG0999983
|
Casio
Electronics
| ₹17,374 | ₹8,760 | 98.3% | 4389 | discontinued | 1.5 ★ |
| #999982 |
Essential Phone 999982
FLG0999982
|
Philippe
Kitchen
| ₹809 | ₹462 | 75.0% | 2372 | draft | 1.3 ★ |
| #999981 |
Ultra Bundle 999981
FLG0999981
|
HP
Clothing
| ₹36,365 | ₹27,792 | 30.8% | 1484 | active | 3.5 ★ |
| #999980 |
Elite Item 999980
FLG0999980
|
Oppo
Electronics
| ₹728 | ₹452 | 61.0% | 4112 | draft | 2.4 ★ |
| #999979 |
Ultra Item 999979
FLG0999979
|
Apple
Garden
| ₹11,188 | ₹7,325 | 52.7% | 581 | active | 4.1 ★ |
| #999978 |
Advanced Game 999978
FLG0999978
|
Oppo
&
| ₹54,688 | ₹28,404 | 92.5% | 4524 | active | 2.4 ★ |
| #999977 |
Pro Diary 999977
FLG0999977
|
Woodland
Home
| ₹15,861 | ₹7,955 | 99.4% | 4806 | active | 3.9 ★ |
| #999976 |
Basic Set 999976
FLG0999976
|
Lenovo
Beauty
| ₹60,511 | ₹32,852 | 84.2% | 3127 | active | 4.1 ★ |
# In your LiveView
def mount(_params, _session, socket) do
{:ok, assign(socket, :data_provider, {__MODULE__, :products, []})}
end
def products do
from p in Demo.Flagship.Product,
join: b in assoc(p, :brand),
as: :brand,
join: c in assoc(p, :category),
as: :category,
select: %{
id: p.id,
sku: p.sku,
name: p.name,
price: p.price,
cost: p.cost,
margin: fragment("round(?, 1)", (p.price - p.cost) / p.cost * 100),
stock_quantity: p.stock_quantity,
status: p.status,
rating: p.rating,
brand: b.name,
category: c.name
}
end
def fields do
[
id: %{label: "ID", sortable: true, renderer: &id/1},
name: %{label: "Product", sortable: true, searchable: true, renderer: &product/2},
brand: %{
label: "Brand",
sortable: true,
searchable: true,
assoc: {:brand, :name},
renderer: &brand/2
},
price: %{label: "Price", sortable: true, renderer: &money/1},
cost: %{label: "Cost", renderer: &cost/1},
margin: %{label: "Margin", renderer: &margin/1},
stock_quantity: %{label: "Stock", sortable: true, renderer: &stock/1},
status: %{label: "Status", renderer: &status/1},
rating: %{label: "Rating", sortable: true, renderer: &rating/1},
sku: %{label: "SKU", searchable: true, hidden: true},
category: %{label: "Category", sortable: true, assoc: {:category, :name}, hidden: true}
]
end
def filters do
[
category:
Select.new({:category, :name}, "category", %{
label: "Category",
mode: :tags,
options_source: {Demo.Flagship, :search_categories, []}
}),
price:
Range.new(:price, "price", %{
label: "Price",
unit: "₹",
min: 0,
max: 250_000,
step: 1000,
pips: true,
pips_mode: "values",
pips_values: [0, 50_000, 100_000, 150_000, 200_000, 250_000]
}),
featured:
Boolean.new(:is_featured, "featured", %{
label: "Featured",
condition: dynamic([p], p.is_featured)
}),
in_stock:
Boolean.new(:stock_quantity, "in_stock", %{
label: "In stock",
condition: dynamic([p], p.stock_quantity > 0)
}),
top_rated:
Boolean.new(:rating, "top_rated", %{
label: "Rated 4+",
condition: dynamic([p], p.rating >= 4.0)
})
]
end
def table_options do
%{
pagination: %{sizes: [25, 50], default_size: 25},
sorting: %{default_sort: [id: :desc]},
search: %{placeholder: "Search a million products"},
exports: %{enabled: true, formats: [:csv, :pdf]},
fixed_header: true
}
end