instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
from typing import List, TypedDict
class NavItem(TypedDict):
name: str
icon: str
active: bool
|
class BillingStat(TypedDict):
label: str
value: str
total: str
percentage: float
class CostItem(TypedDict):
label: str
value: str
value_num: float
percentage: float
color: str
class ChartDataPoint(TypedDict):
date: str
value1: int
value2: int
class OverviewMetric... | class ShortcutItem(TypedDict):
name: str
icon: str |
import reflex as rx
from retail_analytics_dashboard.models.models import (
BillingStat,
CostItem,
NavItem,
OverviewMetric,
ShortcutItem,
)
from retail_analytics_dashboard.states.data import overview_metrics_data
class DashboardState(rx.State):
nav_items: List[NavItem] = [
{
... | from typing import Dict, List | |
from typing import Dict, List
|
from retail_analytics_dashboard.models.models import (
BillingStat,
CostItem,
NavItem,
OverviewMetric,
ShortcutItem,
)
from retail_analytics_dashboard.states.data import overview_metrics_data
class DashboardState(rx.State):
nav_items: List[NavItem] = [
{
"name": "Overview... | import reflex as rx |
from typing import Dict, List
import reflex as rx
|
from retail_analytics_dashboard.states.data import overview_metrics_data
class DashboardState(rx.State):
nav_items: List[NavItem] = [
{
"name": "Overview",
"icon": "home",
"active": True,
},
{
"name": "Details",
"icon": "list",
... | from retail_analytics_dashboard.models.models import (
BillingStat,
CostItem,
NavItem,
OverviewMetric,
ShortcutItem,
) |
from typing import Dict, List
import reflex as rx
from retail_analytics_dashboard.models.models import (
BillingStat,
CostItem,
NavItem,
OverviewMetric,
ShortcutItem,
)
|
class DashboardState(rx.State):
nav_items: List[NavItem] = [
{
"name": "Overview",
"icon": "home",
"active": True,
},
{
"name": "Details",
"icon": "list",
"active": False,
},
{
"name": "Set... | from retail_analytics_dashboard.states.data import overview_metrics_data |
"total": "100%",
"percentage": 98.3,
},
]
total_budget: float = 328.0
billing_costs_items: List[CostItem] = [
{
"label": "Base tier",
"value": "$200",
"value_num": 200.0,
"percentage": 68.1,
"color": "bg-indigo-60... |
@rx.var
def remaining_budget_value(self) -> float:
"""Calculates the remaining budget value."""
return self.total_budget - self.current_total_cost
@rx.var
def remaining_budget_percentage(self) -> float:
"""Calculates the remaining budget percentage."""
if self.total_bu... | def current_total_cost(self) -> float:
"""Calculates the current total cost from the breakdown items."""
return sum((item["value_num"] for item in self.billing_costs_items)) |
arges",
"value": "$61.1",
"value_num": 61.1,
"percentage": 20.8,
"color": "bg-purple-600",
},
{
"label": "Caching",
"value": "$31.9",
"value_num": 31.9,
"percentage": 11.1,
"color": "bg-gray-400",... |
@rx.var
def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_items))
@rx.var
def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
"""Returns... | def remaining_budget_percentage(self) -> float:
"""Calculates the remaining budget percentage."""
if self.total_budget == 0:
return 0.0
percentage = self.remaining_budget_value / self.total_budget * 100
return round(percentage * 10) / 10 |
color": "bg-purple-600",
},
{
"label": "Caching",
"value": "$31.9",
"value_num": 31.9,
"percentage": 11.1,
"color": "bg-gray-400",
},
]
overview_metrics: List[OverviewMetric] = overview_metrics_data
chart_visibility: Dict[st... |
percentage = self.remaining_budget_value / self.total_budget * 100
return round(percentage * 10) / 10
@rx.var
def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_... | if self.total_budget == 0:
return 0.0 |
"label": "Caching",
"value": "$31.9",
"value_num": 31.9,
"percentage": 11.1,
"color": "bg-gray-400",
},
]
overview_metrics: List[OverviewMetric] = overview_metrics_data
chart_visibility: Dict[str, bool] = {
metric["id"]: True for metric in over... |
return round(percentage * 10) / 10
@rx.var
def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_items))
@rx.var
def visible_overview_metrics(
self,
) ... | percentage = self.remaining_budget_value / self.total_budget * 100 |
olor": "bg-gray-400",
},
]
overview_metrics: List[OverviewMetric] = overview_metrics_data
chart_visibility: Dict[str, bool] = {
metric["id"]: True for metric in overview_metrics_data
}
temp_chart_visibility: Dict[str, bool] = {}
show_customize_dialog: bool = False
@rx.var
... |
@rx.var
def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
"""Returns the list of overview metrics that are marked as visible."""
return [
metric
for metric in self.overview_metrics
if self.chart_visibility.get(metric["id"], False)
... | def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_items)) |
a
}
temp_chart_visibility: Dict[str, bool] = {}
show_customize_dialog: bool = False
@rx.var
def current_total_cost(self) -> float:
"""Calculates the current total cost from the breakdown items."""
return sum((item["value_num"] for item in self.billing_costs_items))
@rx.var
... |
@rx.event
def set_active_nav(self, item_name: str):
new_nav_items = []
for item in self.nav_items:
new_item = item.copy()
new_item["active"] = item["name"] == item_name
new_nav_items.append(new_item)
self.nav_items = new_nav_items
@rx.event
... | def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
"""Returns the list of overview metrics that are marked as visible."""
return [
metric
for metric in self.overview_metrics
if self.chart_visibility.get(metric["id"], False)
] |
ning_budget_value(self) -> float:
"""Calculates the remaining budget value."""
return self.total_budget - self.current_total_cost
@rx.var
def remaining_budget_percentage(self) -> float:
"""Calculates the remaining budget percentage."""
if self.total_budget == 0:
retu... |
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_customize_dialog
if self.show_customize_dialog:
self.temp_chart_visibility = self.chart_visibility.copy()
... | def set_active_nav(self, item_name: str):
new_nav_items = []
for item in self.nav_items:
new_item = item.copy()
new_item["active"] = item["name"] == item_name
new_nav_items.append(new_item)
self.nav_items = new_nav_items |
lates the remaining budget value."""
return self.total_budget - self.current_total_cost
@rx.var
def remaining_budget_percentage(self) -> float:
"""Calculates the remaining budget percentage."""
if self.total_budget == 0:
return 0.0
percentage = self.remaining_budget_... |
for item in self.nav_items:
new_item = item.copy()
new_item["active"] = item["name"] == item_name
new_nav_items.append(new_item)
self.nav_items = new_nav_items
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and in... | new_nav_items = [] |
value."""
return self.total_budget - self.current_total_cost
@rx.var
def remaining_budget_percentage(self) -> float:
"""Calculates the remaining budget percentage."""
if self.total_budget == 0:
return 0.0
percentage = self.remaining_budget_value / self.total_budget *... |
self.nav_items = new_nav_items
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_customize_dialog
if self.show_customize_dialog:
self.temp_chart_vis... | for item in self.nav_items:
new_item = item.copy()
new_item["active"] = item["name"] == item_name
new_nav_items.append(new_item) |
et - self.current_total_cost
@rx.var
def remaining_budget_percentage(self) -> float:
"""Calculates the remaining budget percentage."""
if self.total_budget == 0:
return 0.0
percentage = self.remaining_budget_value / self.total_budget * 100
return round(percentage * 1... |
new_item["active"] = item["name"] == item_name
new_nav_items.append(new_item)
self.nav_items = new_nav_items
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog =... | new_item = item.copy() |
get percentage."""
if self.total_budget == 0:
return 0.0
percentage = self.remaining_budget_value / self.total_budget * 100
return round(percentage * 10) / 10
@rx.var
def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost item... |
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_customize_dialog
if self.show_customize_dialog:
self.temp_chart_visibility = self.chart_visibility.copy()
... | self.nav_items = new_nav_items |
0:
return 0.0
percentage = self.remaining_budget_value / self.total_budget * 100
return round(percentage * 10) / 10
@rx.var
def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for i... |
@rx.event
def toggle_temp_chart_visibility(self, chart_id: str):
"""Toggles the visibility of a specific chart in the temporary state."""
if chart_id in self.temp_chart_visibility:
self.temp_chart_visibility[chart_id] = not self.temp_chart_visibility[
chart_id
... | def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_customize_dialog
if self.show_customize_dialog:
self.temp_chart_visibility = self.chart_visibility.copy() |
ge * 10) / 10
@rx.var
def total_cost_percentage(self) -> float:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_items))
@rx.var
def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
... |
if self.show_customize_dialog:
self.temp_chart_visibility = self.chart_visibility.copy()
@rx.event
def toggle_temp_chart_visibility(self, chart_id: str):
"""Toggles the visibility of a specific chart in the temporary state."""
if chart_id in self.temp_chart_visibility:
... | self.show_customize_dialog = not self.show_customize_dialog |
oat:
"""Calculates the total percentage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_items))
@rx.var
def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
"""Returns the list of overview metrics that are marked as visibl... |
@rx.event
def toggle_temp_chart_visibility(self, chart_id: str):
"""Toggles the visibility of a specific chart in the temporary state."""
if chart_id in self.temp_chart_visibility:
self.temp_chart_visibility[chart_id] = not self.temp_chart_visibility[
chart_id
... | if self.show_customize_dialog:
self.temp_chart_visibility = self.chart_visibility.copy() |
tage used based on cost items."""
return sum((item["percentage"] for item in self.billing_costs_items))
@rx.var
def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
"""Returns the list of overview metrics that are marked as visible."""
return [
metric
... |
@rx.event
def toggle_temp_chart_visibility(self, chart_id: str):
"""Toggles the visibility of a specific chart in the temporary state."""
if chart_id in self.temp_chart_visibility:
self.temp_chart_visibility[chart_id] = not self.temp_chart_visibility[
chart_id
... | self.temp_chart_visibility = self.chart_visibility.copy() |
item in self.billing_costs_items))
@rx.var
def visible_overview_metrics(
self,
) -> List[OverviewMetric]:
"""Returns the list of overview metrics that are marked as visible."""
return [
metric
for metric in self.overview_metrics
if self.chart_visi... |
@rx.event
def apply_chart_visibility(self):
"""Applies the temporary visibility settings to the actual state and closes the dialog."""
self.chart_visibility = self.temp_chart_visibility.copy()
self.show_customize_dialog = False
@rx.event
def cancel_chart_visibility(self):
... | def toggle_temp_chart_visibility(self, chart_id: str):
"""Toggles the visibility of a specific chart in the temporary state."""
if chart_id in self.temp_chart_visibility:
self.temp_chart_visibility[chart_id] = not self.temp_chart_visibility[
chart_id
] |
s the list of overview metrics that are marked as visible."""
return [
metric
for metric in self.overview_metrics
if self.chart_visibility.get(metric["id"], False)
]
@rx.event
def set_active_nav(self, item_name: str):
new_nav_items = []
for it... |
@rx.event
def apply_chart_visibility(self):
"""Applies the temporary visibility settings to the actual state and closes the dialog."""
self.chart_visibility = self.temp_chart_visibility.copy()
self.show_customize_dialog = False
@rx.event
def cancel_chart_visibility(self):
... | if chart_id in self.temp_chart_visibility:
self.temp_chart_visibility[chart_id] = not self.temp_chart_visibility[
chart_id
] |
le."""
return [
metric
for metric in self.overview_metrics
if self.chart_visibility.get(metric["id"], False)
]
@rx.event
def set_active_nav(self, item_name: str):
new_nav_items = []
for item in self.nav_items:
new_item = item.copy(... |
@rx.event
def apply_chart_visibility(self):
"""Applies the temporary visibility settings to the actual state and closes the dialog."""
self.chart_visibility = self.temp_chart_visibility.copy()
self.show_customize_dialog = False
@rx.event
def cancel_chart_visibility(self):
... | self.temp_chart_visibility[chart_id] = not self.temp_chart_visibility[
chart_id
] |
et(metric["id"], False)
]
@rx.event
def set_active_nav(self, item_name: str):
new_nav_items = []
for item in self.nav_items:
new_item = item.copy()
new_item["active"] = item["name"] == item_name
new_nav_items.append(new_item)
self.nav_items = ... |
@rx.event
def cancel_chart_visibility(self):
"""Closes the dialog without applying changes."""
self.show_customize_dialog = False
| def apply_chart_visibility(self):
"""Applies the temporary visibility settings to the actual state and closes the dialog."""
self.chart_visibility = self.temp_chart_visibility.copy()
self.show_customize_dialog = False |
w_item["active"] = item["name"] == item_name
new_nav_items.append(new_item)
self.nav_items = new_nav_items
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_... |
@rx.event
def cancel_chart_visibility(self):
"""Closes the dialog without applying changes."""
self.show_customize_dialog = False
| self.show_customize_dialog = False |
new_nav_items.append(new_item)
self.nav_items = new_nav_items
@rx.event
def toggle_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_customize_dialog
if self.show_customize_dialog... | def cancel_chart_visibility(self):
"""Closes the dialog without applying changes."""
self.show_customize_dialog = False | |
e_customize_dialog(self):
"""Toggles the customize charts dialog and initializes temporary visibility."""
self.show_customize_dialog = not self.show_customize_dialog
if self.show_customize_dialog:
self.temp_chart_visibility = self.chart_visibility.copy()
@rx.event
def toggle... | self.show_customize_dialog = False | |
from retail_analytics_dashboard.models.models import OverviewMetric
from retail_analytics_dashboard.states.utils import generate_chart_data
TOOLTIP_PROPS = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px ... | from typing import List | |
from typing import List
|
from retail_analytics_dashboard.states.utils import generate_chart_data
TOOLTIP_PROPS = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 8px ... | from retail_analytics_dashboard.models.models import OverviewMetric |
from typing import List
from retail_analytics_dashboard.models.models import OverviewMetric
|
TOOLTIP_PROPS = {
"content_style": {
"background": "white",
"borderColor": "#E8E8E8",
"borderRadius": "0.75rem",
"boxShadow": "0px 24px 12px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 8px 8px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 2px... | from retail_analytics_dashboard.states.utils import generate_chart_data |
import random
from typing import List
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150,
) -> List[Cha... | import datetime | |
import datetime
|
from typing import List
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150,
) -> List[ChartDataPoint]:
... | import random |
import datetime
import random
|
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150,
) -> List[ChartDataPoint]:
data: List[ChartData... | from typing import List |
import datetime
import random
from typing import List
|
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150,
) -> List[ChartDataPoint]:
data: List[ChartDataPoint] = []
start_date = datetime.datetime.strptime(start_date_st... | from retail_analytics_dashboard.models.models import ChartDataPoint |
import datetime
import random
from typing import List
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150... |
end_date = datetime.datetime.strptime(end_date_str, "%d/%m/%Y")
date_delta = (end_date - start_date) / (num_points - 1)
for i in range(num_points):
current_date = start_date + date_delta * i
data.append(
{
"date": current_date.strftime("%d/%m/%Y"),
... | start_date = datetime.datetime.strptime(start_date_str, "%d/%m/%Y") |
import datetime
import random
from typing import List
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150... |
date_delta = (end_date - start_date) / (num_points - 1)
for i in range(num_points):
current_date = start_date + date_delta * i
data.append(
{
"date": current_date.strftime("%d/%m/%Y"),
"value1": random.randint(min_val1, max_val1),
"val... | end_date = datetime.datetime.strptime(end_date_str, "%d/%m/%Y") |
import datetime
import random
from typing import List
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150... |
for i in range(num_points):
current_date = start_date + date_delta * i
data.append(
{
"date": current_date.strftime("%d/%m/%Y"),
"value1": random.randint(min_val1, max_val1),
"value2": random.randint(min_val2, max_val2),
}
... | date_delta = (end_date - start_date) / (num_points - 1) |
import datetime
import random
from typing import List
from retail_analytics_dashboard.models.models import ChartDataPoint
def generate_chart_data(
start_date_str: str,
end_date_str: str,
num_points: int = 30,
min_val1: int = 50,
max_val1: int = 200,
min_val2: int = 30,
max_val2: int = 150... |
data.append(
{
"date": current_date.strftime("%d/%m/%Y"),
"value1": random.randint(min_val1, max_val1),
"value2": random.randint(min_val2, max_val2),
}
)
return data
| current_date = start_date + date_delta * i |
import reflex as rx
from retail_dashboard.components.sidebar import sidebar
from retail_dashboard.pages.details_page import details_page_layout
from retail_dashboard.states.dashboard_state import DashboardState
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.Component:
"""Main page... | from typing import Callable | |
from typing import Callable
|
from retail_dashboard.components.sidebar import sidebar
from retail_dashboard.pages.details_page import details_page_layout
from retail_dashboard.states.dashboard_state import DashboardState
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.Component:
"""Main page layout with sidebar ... | import reflex as rx |
from typing import Callable
import reflex as rx
|
from retail_dashboard.pages.details_page import details_page_layout
from retail_dashboard.states.dashboard_state import DashboardState
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.Component:
"""Main page layout with sidebar and content area."""
return rx.el.div(
sideba... | from retail_dashboard.components.sidebar import sidebar |
from typing import Callable
import reflex as rx
from retail_dashboard.components.sidebar import sidebar
|
from retail_dashboard.states.dashboard_state import DashboardState
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.Component:
"""Main page layout with sidebar and content area."""
return rx.el.div(
sidebar(),
rx.el.main(
content_func(),
cla... | from retail_dashboard.pages.details_page import details_page_layout |
from typing import Callable
import reflex as rx
from retail_dashboard.components.sidebar import sidebar
from retail_dashboard.pages.details_page import details_page_layout
|
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.Component:
"""Main page layout with sidebar and content area."""
return rx.el.div(
sidebar(),
rx.el.main(
content_func(),
class_name="flex-1 overflow-y-auto bg-gray-50 p-0",
),
... | from retail_dashboard.states.dashboard_state import DashboardState |
from typing import Callable
import reflex as rx
from retail_dashboard.components.sidebar import sidebar
from retail_dashboard.pages.details_page import details_page_layout
from retail_dashboard.states.dashboard_state import DashboardState
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.... |
def index() -> rx.Component:
"""Default route, now pointing to details page."""
return details_route()
app = rx.App(
theme=rx.theme(appearance="light"),
head_components=[
rx.el.link(
rel="preconnect",
href="https://fonts.googleapis.com",
),
rx.el.link... | def details_route() -> rx.Component:
"""Route for the Details page."""
return page_with_sidebar(details_page_layout) |
dashboard.pages.details_page import details_page_layout
from retail_dashboard.states.dashboard_state import DashboardState
def page_with_sidebar(
content_func: Callable[[], rx.Component],
) -> rx.Component:
"""Main page layout with sidebar and content area."""
return rx.el.div(
sidebar(),
... |
app = rx.App(
theme=rx.theme(appearance="light"),
head_components=[
rx.el.link(
rel="preconnect",
href="https://fonts.googleapis.com",
),
rx.el.link(
rel="preconnect",
href="https://fonts.gstatic.com",
crossorigin="",
... | def index() -> rx.Component:
"""Default route, now pointing to details page."""
return details_route() |
from retail_dashboard.states.dashboard_state import DashboardState
def status_badge(status: rx.Var[str]) -> rx.Component:
"""Creates a colored status badge."""
return rx.el.span(
rx.el.span(
class_name=rx.match(
status,
(
"Live",
... | import reflex as rx | |
import reflex as rx
|
def status_badge(status: rx.Var[str]) -> rx.Component:
"""Creates a colored status badge."""
return rx.el.span(
rx.el.span(
class_name=rx.match(
status,
(
"Live",
"h-1.5 w-1.5 rounded-full bg-emerald-500 mr-1.5",
... | from retail_dashboard.states.dashboard_state import DashboardState |
import reflex as rx
from reflex.event import EventSpec
from retail_dashboard.states.dashboard_state import DashboardState
def filter_checkbox_item(
label: str,
is_checked: rx.Var[bool],
on_change: Callable[[str], None],
show_flag: bool = False,
) -> rx.Component:
"""Component for a single check... | from typing import Callable | |
from typing import Callable
|
from reflex.event import EventSpec
from retail_dashboard.states.dashboard_state import DashboardState
def filter_checkbox_item(
label: str,
is_checked: rx.Var[bool],
on_change: Callable[[str], None],
show_flag: bool = False,
) -> rx.Component:
"""Component for a single checkbox item in a filter ... | import reflex as rx |
from typing import Callable
import reflex as rx
|
from retail_dashboard.states.dashboard_state import DashboardState
def filter_checkbox_item(
label: str,
is_checked: rx.Var[bool],
on_change: Callable[[str], None],
show_flag: bool = False,
) -> rx.Component:
"""Component for a single checkbox item in a filter dropdown."""
return rx.el.label... | from reflex.event import EventSpec |
from typing import Callable
import reflex as rx
from reflex.event import EventSpec
|
def filter_checkbox_item(
label: str,
is_checked: rx.Var[bool],
on_change: Callable[[str], None],
show_flag: bool = False,
) -> rx.Component:
"""Component for a single checkbox item in a filter dropdown."""
return rx.el.label(
rx.el.input(
type="checkbox",
chec... | from retail_dashboard.states.dashboard_state import DashboardState |
-gray-500 px-3 pt-2.5 pb-1.5",
),
content,
rx.el.div(
rx.el.button(
"Reset",
on_click=reset_action,
class_name="px-3.5 py-2 text-sm text-gray-700 hover:bg-gray-100 rounded-lg focus:outline-none focus:ring-1 focus:ring-gray-300",
... |
return filter_dropdown_base(
"Filter by Status",
DashboardState.show_status_filter,
content,
DashboardState.reset_status_filter,
DashboardState.apply_status_filter,
)
def country_filter_dropdown() -> rx.Component:
"""Dropdown component for filtering by Country."""
... | content = rx.el.div(
rx.foreach(
DashboardState.unique_statuses,
lambda status: filter_checkbox_item(
label=status,
is_checked=DashboardState.temp_selected_statuses.contains(status),
on_change=DashboardState.toggle_temp_status,
... |
nded-b-lg",
),
class_name=f"absolute top-full left-0 mt-2 {width_class} border border-gray-200 rounded-lg z-30 bg-white shadow-lg",
hidden=~show_var,
)
def status_filter_dropdown() -> rx.Component:
"""Dropdown component for filtering by Status."""
content = rx.el.div(
rx.fo... |
return filter_dropdown_base(
"Filter by Country",
DashboardState.show_country_filter,
content,
DashboardState.reset_country_filter,
DashboardState.apply_country_filter,
)
def costs_filter_dropdown() -> rx.Component:
"""Dropdown component for filtering by Costs."""
... | content = rx.el.div(
rx.foreach(
DashboardState.unique_countries,
lambda country: filter_checkbox_item(
label=country,
is_checked=DashboardState.temp_selected_countries.contains(country),
on_change=DashboardState.toggle_temp_country,
... |
-500 focus:border-neutral-500",
default_value=DashboardState.temp_min_cost_str,
type="number",
step="0.01",
),
rx.el.input(
placeholder="Max cost",
on_change=DashboardState.set_temp_max_cost,
class_name="w-full p-2.5 border border-g... |
active_class = f"{base_class} border-neutral-500 bg-neutral-50 text-neutral-700 ring-neutral-400"
inactive_class = f"{base_class} border-gray-300 text-gray-700 hover:border-gray-400 hover:bg-gray-50 ring-gray-400"
return rx.el.button(
rx.el.span(label, class_name="flex items-center"),
rx.ic... | base_class = "flex items-center px-3.5 py-2 border rounded-lg text-sm font-medium focus:outline-none focus:ring-1 focus:ring-offset-1" |
01",
),
rx.el.input(
placeholder="Max cost",
on_change=DashboardState.set_temp_max_cost,
class_name="w-full p-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-500 focus:border-neutral-500",
default_value=Dash... |
inactive_class = f"{base_class} border-gray-300 text-gray-700 hover:border-gray-400 hover:bg-gray-50 ring-gray-400"
return rx.el.button(
rx.el.span(label, class_name="flex items-center"),
rx.icon(tag="chevron_down", size=16, class_name="ml-2"),
on_click=on_click,
class_name=rx.c... | active_class = f"{base_class} border-neutral-500 bg-neutral-50 text-neutral-700 ring-neutral-400" |
rdState.set_temp_max_cost,
class_name="w-full p-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-500 focus:border-neutral-500",
default_value=DashboardState.temp_max_cost_str,
type="number",
step="0.01",
),
c... |
return rx.el.button(
rx.el.span(label, class_name="flex items-center"),
rx.icon(tag="chevron_down", size=16, class_name="ml-2"),
on_click=on_click,
class_name=rx.cond(has_filter, active_class, inactive_class),
aria_expanded=is_active,
)
| inactive_class = f"{base_class} border-gray-300 text-gray-700 hover:border-gray-400 hover:bg-gray-50 ring-gray-400" |
from retail_dashboard.components.filter_dropdown import (
costs_filter_dropdown,
country_filter_dropdown,
filter_button,
status_filter_dropdown,
)
from retail_dashboard.states.dashboard_state import DashboardState
def header() -> rx.Component:
"""The header component with title, filters, and act... | import reflex as rx | |
import reflex as rx
|
from retail_dashboard.states.dashboard_state import DashboardState
def header() -> rx.Component:
"""The header component with title, filters, and actions."""
return rx.el.div(
rx.el.div(
rx.el.h1(
"Dashboard",
class_name="text-2xl font-semibold text-gray-80... | from retail_dashboard.components.filter_dropdown import (
costs_filter_dropdown,
country_filter_dropdown,
filter_button,
status_filter_dropdown,
) |
import reflex as rx
from retail_dashboard.components.filter_dropdown import (
costs_filter_dropdown,
country_filter_dropdown,
filter_button,
status_filter_dropdown,
)
|
def header() -> rx.Component:
"""The header component with title, filters, and actions."""
return rx.el.div(
rx.el.div(
rx.el.h1(
"Dashboard",
class_name="text-2xl font-semibold text-gray-800",
),
rx.el.p(
"Manage and... | from retail_dashboard.states.dashboard_state import DashboardState |
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(href, DashboardState... | import reflex as rx | |
import reflex as rx
|
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(href, DashboardState.router.page.path == href, False)
base_class = "flex items-cente... | from retail_dashboard.states.dashboard_state import DashboardState |
import reflex as rx
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
|
base_class = "flex items-center px-3.5 py-2.5 text-sm rounded-lg"
active_class = f"{base_class} font-medium text-neutral-700 bg-neutral-100"
inactive_class = f"{base_class} text-gray-600 hover:bg-gray-100 hover:text-gray-800"
icon_active_class = "text-neutral-700"
icon_inactive_class = "text-gray-4... | current_path_check = rx.cond(href, DashboardState.router.page.path == href, False) |
import reflex as rx
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(h... |
active_class = f"{base_class} font-medium text-neutral-700 bg-neutral-100"
inactive_class = f"{base_class} text-gray-600 hover:bg-gray-100 hover:text-gray-800"
icon_active_class = "text-neutral-700"
icon_inactive_class = "text-gray-400 group-hover:text-gray-500"
link_content = rx.el.span(
r... | base_class = "flex items-center px-3.5 py-2.5 text-sm rounded-lg" |
import reflex as rx
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(h... |
inactive_class = f"{base_class} text-gray-600 hover:bg-gray-100 hover:text-gray-800"
icon_active_class = "text-neutral-700"
icon_inactive_class = "text-gray-400 group-hover:text-gray-500"
link_content = rx.el.span(
rx.icon(
tag=icon_name,
size=18,
class_name=... | active_class = f"{base_class} font-medium text-neutral-700 bg-neutral-100" |
import reflex as rx
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(h... |
icon_active_class = "text-neutral-700"
icon_inactive_class = "text-gray-400 group-hover:text-gray-500"
link_content = rx.el.span(
rx.icon(
tag=icon_name,
size=18,
class_name=rx.cond(
current_path_check,
icon_active_class,
... | inactive_class = f"{base_class} text-gray-600 hover:bg-gray-100 hover:text-gray-800" |
import reflex as rx
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(h... |
icon_inactive_class = "text-gray-400 group-hover:text-gray-500"
link_content = rx.el.span(
rx.icon(
tag=icon_name,
size=18,
class_name=rx.cond(
current_path_check,
icon_active_class,
icon_inactive_class,
)
... | icon_active_class = "text-neutral-700" |
import reflex as rx
from retail_dashboard.states.dashboard_state import DashboardState
def nav_link(
text: str,
icon_name: str,
href: str | None = None,
on_click: rx.event.EventHandler | None = None,
) -> rx.Component:
"""A reusable navigation link component."""
current_path_check = rx.cond(h... |
link_content = rx.el.span(
rx.icon(
tag=icon_name,
size=18,
class_name=rx.cond(
current_path_check,
icon_active_class,
icon_inactive_class,
)
+ " mr-3.5",
),
text,
class_name=... | icon_inactive_class = "text-gray-400 group-hover:text-gray-500" |
from retail_dashboard.components.details_table import details_table
from retail_dashboard.components.header import header as details_page_header
def details_page_layout() -> rx.Component:
"""The main layout for the Details page."""
return rx.el.div(
details_page_header(),
details_table(),
... | import reflex as rx | |
import io
from collections import defaultdict
from typing import Dict, List, Optional, Set
import pandas as pd
import reflex as rx
from retail_dashboard.models.entry import DetailEntry
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_da... | import datetime | |
import datetime
import io
|
from typing import Dict, List, Optional, Set
import pandas as pd
import reflex as rx
from retail_dashboard.models.entry import DetailEntry
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_na... | from collections import defaultdict |
import datetime
import io
from collections import defaultdict
|
import pandas as pd
import reflex as rx
from retail_dashboard.models.entry import DetailEntry
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_names: List[str] = [
"Owner",
"... | from typing import Dict, List, Optional, Set |
import datetime
import io
from collections import defaultdict
from typing import Dict, List, Optional, Set
|
import reflex as rx
from retail_dashboard.models.entry import DetailEntry
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_names: List[str] = [
"Owner",
"Status",
"Cou... | import pandas as pd |
import datetime
import io
from collections import defaultdict
from typing import Dict, List, Optional, Set
import pandas as pd
|
from retail_dashboard.models.entry import DetailEntry
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_names: List[str] = [
"Owner",
"Status",
"Country",
"Stab... | import reflex as rx |
import datetime
import io
from collections import defaultdict
from typing import Dict, List, Optional, Set
import pandas as pd
import reflex as rx
|
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_names: List[str] = [
"Owner",
"Status",
"Country",
"Stability",
"Costs",
"Last edited",
]
... | from retail_dashboard.models.entry import DetailEntry |
import datetime
import io
from collections import defaultdict
from typing import Dict, List, Optional, Set
import pandas as pd
import reflex as rx
from retail_dashboard.models.entry import DetailEntry
|
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_names: List[str] = [
"Owner",
"Status",
"Country",
"Stability",
"Costs",
"Last edited",
]
search_owner: str = ""
selected_statuses: S... | from retail_dashboard.states.data import raw_data |
reflex as rx
from retail_dashboard.models.entry import DetailEntry
from retail_dashboard.states.data import raw_data
class DashboardState(rx.State):
"""State for the dashboard page."""
_data: List[DetailEntry] = raw_data
column_names: List[str] = [
"Owner",
"Status",
"Country",
... |
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live"))
@rx.v... | def _parse_datetime_for_costs(
self, item: DetailEntry, input_format: str
) -> Optional[tuple[datetime.datetime, float]]:
"""Helper to parse datetime and return (datetime, costs) or None on error."""
try:
dt_obj = datetime.datetime.strptime(item["last_edited"], input_format)
... |
names: List[str] = [
"Owner",
"Status",
"Country",
"Stability",
"Costs",
"Last edited",
]
search_owner: str = ""
selected_statuses: Set[str] = set()
selected_countries: Set[str] = set()
min_cost: Optional[float] = None
max_cost: Optional[float] = N... |
return dt_obj, item["costs"]
except ValueError:
return None
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entri... | dt_obj = datetime.datetime.strptime(item["last_edited"], input_format) |
d_statuses: Set[str] = set()
selected_countries: Set[str] = set()
min_cost: Optional[float] = None
max_cost: Optional[float] = None
temp_selected_statuses: Set[str] = set()
temp_selected_countries: Set[str] = set()
temp_min_cost_str: str = ""
temp_max_cost_str: str = ""
show_status_filte... |
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live"))
@rx.var
def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum((1 for item in self._data if it... | def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data) |
ne
temp_selected_statuses: Set[str] = set()
temp_selected_countries: Set[str] = set()
temp_min_cost_str: str = ""
temp_max_cost_str: str = ""
show_status_filter: bool = False
show_country_filter: bool = False
show_costs_filter: bool = False
sort_column: Optional[str] = None
sort_asce... |
@rx.var
def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum((1 for item in self._data if item["status"] == "Inactive"))
@rx.var
def archived_entries_count(self) -> int:
"""Count of 'Archived' entries."""
return sum((1 for item in self... | def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live")) |
tatus_filter: bool = False
show_country_filter: bool = False
show_costs_filter: bool = False
sort_column: Optional[str] = None
sort_ascending: bool = True
selected_rows: Set[int] = set()
current_page: int = 1
rows_per_page: int = 10
def _parse_datetime_for_costs(
self, item: Det... |
@rx.var
def archived_entries_count(self) -> int:
"""Count of 'Archived' entries."""
return sum((1 for item in self._data if item["status"] == "Archived"))
@rx.var
def costs_trend_data(
self,
) -> List[Dict[str, str | float]]:
"""Data for the costs trend line chart.... | def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum((1 for item in self._data if item["status"] == "Inactive")) |
ted_rows: Set[int] = set()
current_page: int = 1
rows_per_page: int = 10
def _parse_datetime_for_costs(
self, item: DetailEntry, input_format: str
) -> Optional[tuple[datetime.datetime, float]]:
"""Helper to parse datetime and return (datetime, costs) or None on error."""
try:
... |
@rx.var
def costs_trend_data(
self,
) -> List[Dict[str, str | float]]:
"""Data for the costs trend line chart."""
daily_costs = defaultdict(float)
input_format = "%d/%m/%Y %H:%M"
output_format = "%Y-%m-%d"
display_format = "%b %d"
valid_items = []
... | def archived_entries_count(self) -> int:
"""Count of 'Archived' entries."""
return sum((1 for item in self._data if item["status"] == "Archived")) |
ional[tuple[datetime.datetime, float]]:
"""Helper to parse datetime and return (datetime, costs) or None on error."""
try:
dt_obj = datetime.datetime.strptime(item["last_edited"], input_format)
return dt_obj, item["costs"]
except ValueError:
return None
@... |
@rx.var
def recent_activities(self) -> List[DetailEntry]:
"""Get the 5 most recent activities based on last_edited date."""
# Precompute sort keys to move try-except out of the sorting process itself
items_with_sort_keys = [
(self._get_sort_key_for_recent_activities(item), ... | def costs_trend_data(
self,
) -> List[Dict[str, str | float]]:
"""Data for the costs trend line chart."""
daily_costs = defaultdict(float)
input_format = "%d/%m/%Y %H:%M"
output_format = "%Y-%m-%d"
display_format = "%b %d"
valid_items = []
for item i... |
try:
dt_obj = datetime.datetime.strptime(item["last_edited"], input_format)
return dt_obj, item["costs"]
except ValueError:
return None
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)... |
input_format = "%d/%m/%Y %H:%M"
output_format = "%Y-%m-%d"
display_format = "%b %d"
valid_items = []
for item in self._data:
parsed_item = self._parse_datetime_for_costs(item, input_format)
if parsed_item:
valid_items.append(parsed_item)... | daily_costs = defaultdict(float) |
e.strptime(item["last_edited"], input_format)
return dt_obj, item["costs"]
except ValueError:
return None
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(s... |
output_format = "%Y-%m-%d"
display_format = "%b %d"
valid_items = []
for item in self._data:
parsed_item = self._parse_datetime_for_costs(item, input_format)
if parsed_item:
valid_items.append(parsed_item)
for dt_obj, cost in valid_items... | input_format = "%d/%m/%Y %H:%M" |
rmat)
return dt_obj, item["costs"]
except ValueError:
return None
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' ... |
display_format = "%b %d"
valid_items = []
for item in self._data:
parsed_item = self._parse_datetime_for_costs(item, input_format)
if parsed_item:
valid_items.append(parsed_item)
for dt_obj, cost in valid_items:
date_str = dt_obj.str... | output_format = "%Y-%m-%d" |
ror:
return None
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["sta... |
for item in self._data:
parsed_item = self._parse_datetime_for_costs(item, input_format)
if parsed_item:
valid_items.append(parsed_item)
for dt_obj, cost in valid_items:
date_str = dt_obj.strftime(output_format)
daily_costs[date_str] += c... | valid_items = [] |
one
@rx.var
def total_entries_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live"))
@r... |
for dt_obj, cost in valid_items:
date_str = dt_obj.strftime(output_format)
daily_costs[date_str] += cost
sorted_dates = sorted(daily_costs.keys())
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, ou... | for item in self._data:
parsed_item = self._parse_datetime_for_costs(item, input_format)
if parsed_item:
valid_items.append(parsed_item) |
es_count(self) -> int:
"""Total number of entries in the raw data."""
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live"))
@rx.var
def inactive_entries_count... |
if parsed_item:
valid_items.append(parsed_item)
for dt_obj, cost in valid_items:
date_str = dt_obj.strftime(output_format)
daily_costs[date_str] += cost
sorted_dates = sorted(daily_costs.keys())
chart_data: List[Dict[str, str | float]] = [
... | parsed_item = self._parse_datetime_for_costs(item, input_format) |
return len(self._data)
@rx.var
def live_entries_count(self) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live"))
@rx.var
def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum(... |
for dt_obj, cost in valid_items:
date_str = dt_obj.strftime(output_format)
daily_costs[date_str] += cost
sorted_dates = sorted(daily_costs.keys())
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, ou... | if parsed_item:
valid_items.append(parsed_item) |
elf) -> int:
"""Count of 'Live' entries."""
return sum((1 for item in self._data if item["status"] == "Live"))
@rx.var
def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum((1 for item in self._data if item["status"] == "Inactive"))
@rx.var
... |
sorted_dates = sorted(daily_costs.keys())
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, output_format).strftime(
display_format
),
"total_costs": round(daily_costs[date_str], 2... | for dt_obj, cost in valid_items:
date_str = dt_obj.strftime(output_format)
daily_costs[date_str] += cost |
es."""
return sum((1 for item in self._data if item["status"] == "Live"))
@rx.var
def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum((1 for item in self._data if item["status"] == "Inactive"))
@rx.var
def archived_entries_count(self) -> int:
... |
daily_costs[date_str] += cost
sorted_dates = sorted(daily_costs.keys())
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, output_format).strftime(
display_format
),
"to... | date_str = dt_obj.strftime(output_format) |
r
def inactive_entries_count(self) -> int:
"""Count of 'Inactive' entries."""
return sum((1 for item in self._data if item["status"] == "Inactive"))
@rx.var
def archived_entries_count(self) -> int:
"""Count of 'Archived' entries."""
return sum((1 for item in self._data if it... |
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, output_format).strftime(
display_format
),
"total_costs": round(daily_costs[date_str], 2),
}
for date_str in sorted... | sorted_dates = sorted(daily_costs.keys()) |
str, str | float]]:
"""Data for the costs trend line chart."""
daily_costs = defaultdict(float)
input_format = "%d/%m/%Y %H:%M"
output_format = "%Y-%m-%d"
display_format = "%b %d"
valid_items = []
for item in self._data:
parsed_item = self._parse_dat... |
def _get_sort_key_for_recent_activities(
self, item: DetailEntry
) -> datetime.datetime:
"""Helper to get sort key for recent activities, handling potential ValueError."""
try:
return datetime.datetime.strptime(item["last_edited"], "%d/%m/%Y %H:%M")
except ValueErro... | def recent_activities(self) -> List[DetailEntry]:
"""Get the 5 most recent activities based on last_edited date."""
# Precompute sort keys to move try-except out of the sorting process itself
items_with_sort_keys = [
(self._get_sort_key_for_recent_activities(item), item)
... |
%d"
valid_items = []
for item in self._data:
parsed_item = self._parse_datetime_for_costs(item, input_format)
if parsed_item:
valid_items.append(parsed_item)
for dt_obj, cost in valid_items:
date_str = dt_obj.strftime(output_format)
... |
# Sort based on the precomputed keys
items_with_sort_keys.sort(key=lambda x: x[0], reverse=True)
# Extract the original items in sorted order
sorted_data = [item for _, item in items_with_sort_keys]
return sorted_data[:5]
def _get_sort_key_for_recent_activities(
s... | items_with_sort_keys = [
(self._get_sort_key_for_recent_activities(item), item)
for item in self._data
] |
daily_costs[date_str] += cost
sorted_dates = sorted(daily_costs.keys())
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, output_format).strftime(
display_format
),
"tota... |
return sorted_data[:5]
def _get_sort_key_for_recent_activities(
self, item: DetailEntry
) -> datetime.datetime:
"""Helper to get sort key for recent activities, handling potential ValueError."""
try:
return datetime.datetime.strptime(item["last_edited"], "%d/%m/%Y %... | sorted_data = [item for _, item in items_with_sort_keys] |
chart_data: List[Dict[str, str | float]] = [
{
"date": datetime.datetime.strptime(date_str, output_format).strftime(
display_format
),
"total_costs": round(daily_costs[date_str], 2),
}
for date_str in sorted_d... |
@rx.var
def unique_statuses(self) -> List[str]:
"""Get unique statuses from the data."""
return sorted({item["status"] for item in self._data})
@rx.var
def unique_countries(self) -> List[str]:
"""Get unique countries from the data."""
return sorted({item["country"] for... | def _get_sort_key_for_recent_activities(
self, item: DetailEntry
) -> datetime.datetime:
"""Helper to get sort key for recent activities, handling potential ValueError."""
try:
return datetime.datetime.strptime(item["last_edited"], "%d/%m/%Y %H:%M")
except ValueError:
... |
def recent_activities(self) -> List[DetailEntry]:
"""Get the 5 most recent activities based on last_edited date."""
# Precompute sort keys to move try-except out of the sorting process itself
items_with_sort_keys = [
(self._get_sort_key_for_recent_activities(item), item)
... |
@rx.var
def unique_countries(self) -> List[str]:
"""Get unique countries from the data."""
return sorted({item["country"] for item in self._data})
@rx.var
def filtered_data(self) -> List[DetailEntry]:
"""Filter the data based on current filter selections."""
data = sel... | def unique_statuses(self) -> List[str]:
"""Get unique statuses from the data."""
return sorted({item["status"] for item in self._data}) |
-except out of the sorting process itself
items_with_sort_keys = [
(self._get_sort_key_for_recent_activities(item), item)
for item in self._data
]
# Sort based on the precomputed keys
items_with_sort_keys.sort(key=lambda x: x[0], reverse=True)
# Extract ... |
@rx.var
def filtered_data(self) -> List[DetailEntry]:
"""Filter the data based on current filter selections."""
data = self._data
if self.search_owner:
data = [
item
for item in data
if self.search_owner.lower() in item["owner... | def unique_countries(self) -> List[str]:
"""Get unique countries from the data."""
return sorted({item["country"] for item in self._data}) |
data
]
# Sort based on the precomputed keys
items_with_sort_keys.sort(key=lambda x: x[0], reverse=True)
# Extract the original items in sorted order
sorted_data = [item for _, item in items_with_sort_keys]
return sorted_data[:5]
def _get_sort_key_for_recent_activit... |
def _get_sort_key_for_filtered_data(
self, item: DetailEntry, internal_key: str, is_date_col: bool
) -> datetime.datetime | str | int | float:
"""Helper to get sort key for filtered_and_sorted_data."""
try:
if is_date_col:
return datetime.datetime.strptime(i... | def filtered_data(self) -> List[DetailEntry]:
"""Filter the data based on current filter selections."""
data = self._data
if self.search_owner:
data = [
item
for item in data
if self.search_owner.lower() in item["owner"].lower()
... |
se=True)
# Extract the original items in sorted order
sorted_data = [item for _, item in items_with_sort_keys]
return sorted_data[:5]
def _get_sort_key_for_recent_activities(
self, item: DetailEntry
) -> datetime.datetime:
"""Helper to get sort key for recent activities... |
if self.search_owner:
data = [
item
for item in data
if self.search_owner.lower() in item["owner"].lower()
]
if self.selected_statuses:
data = [item for item in data if item["status"] in self.selected_statuses]
... | data = self._data |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.