Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/_example/django/django_demo/app/flask_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Meta:


class FlaskCustomer(models.Model):
id = models.BinaryField(primary_key=True, db_column="pk")
id = models.UUIDField(primary_key=True, db_column="pk")
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
birthday_date = models.DateTimeField(blank=True, null=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Self
from typing import Any, Dict, List

from aiohttp import ClientSession
from forestadmin.agent_toolkit.utils.context import User
Expand All @@ -10,6 +10,7 @@
from forestadmin.datasource_toolkit.interfaces.query.filter.paginated import PaginatedFilter
from forestadmin.datasource_toolkit.interfaces.query.filter.unpaginated import Filter
from forestadmin.datasource_toolkit.interfaces.query.projections import Projection
from typing_extensions import Self


class TypicodeCollection(Collection):
Expand Down
4 changes: 2 additions & 2 deletions src/_example/django/django_demo/app/forest/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ async def time_order_number_chart(


async def order_details(context: CollectionChartContext, result_builder: ResultBuilderChart, ids: CompositeIdAlias):
orders = await context.datasource.get_collection("order").list(
orders = await context.datasource.get_collection("app_order").list(
context.caller,
PaginatedFilter(
{"condition_tree": ConditionTreeLeaf("customer_id", "in", ids)},
),
Projection("id", "customer_full_name"),
Projection("id", "customer_full_name", "amount"),
)
return result_builder.smart(orders)

Expand Down
11 changes: 8 additions & 3 deletions src/_example/django/django_demo/app/forest/order.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import json
from datetime import date
from typing import List

from app.models import Order
Expand Down Expand Up @@ -184,14 +185,18 @@ async def refund_order_execute(context: ActionContextSingle, result_builder: Res

# charts
async def total_order_chart(context: AgentCustomizationContext, result_builder: ResultBuilderChart):
records = await context.datasource.get_collection("app_order").list(context.caller, PaginatedFilter({}), ["id"])
return result_builder.value(len(records))
# records = await context.datasource.get_collection("app_order").list(context.caller, PaginatedFilter({}), ["id"])
# return result_builder.value(len(records))
record = await context.datasource.get_collection("app_order").aggregate(
context.caller, Filter({}), Aggregation({"operation": "Count"})
)
return result_builder.value(record[0]["value"])


async def nb_order_per_week(context: AgentCustomizationContext, result_builder: ResultBuilderChart):
records = await context.datasource.get_collection("app_order").aggregate(
context.caller,
Filter({"condition_tree": ConditionTreeLeaf("created_at", "before", "2022-01-01")}),
Filter({"condition_tree": ConditionTreeLeaf("created_at", "before", date.today())}),
Aggregation(
{
"field": "created_at",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _populate_addresses(session, customers: List[Customer]) -> List[Address]:

for _ in range(0, 1000):
address = Address(
street=fake.street_address(), city=fake.city(), country=fake.country(), zip_code=fake.postcode()
street=fake.street_address(), city=fake.city(), country=fake.country(), zip_code=fr_fake.postcode()
)
known_customer: Set[Customer] = set()
for _ in range(1, random.randint(2, 4)):
Expand Down
73 changes: 17 additions & 56 deletions src/_example/django/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 14 additions & 53 deletions src/_example/flask_sqlalchemy_package/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/agent_toolkit/forestadmin/agent_toolkit/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from forestadmin.agent_toolkit.services.permissions.ip_whitelist_service import IpWhiteListService
from forestadmin.agent_toolkit.services.permissions.permission_service import PermissionService
from forestadmin.agent_toolkit.services.permissions.sse_cache_invalidation import SSECacheInvalidation
from forestadmin.agent_toolkit.services.serializers.json_api import create_json_api_schema
from forestadmin.agent_toolkit.utils.context import HttpResponseBuilder
from forestadmin.agent_toolkit.utils.forest_schema.emitter import SchemaEmitter
from forestadmin.agent_toolkit.utils.forest_schema.type import AgentMeta
Expand Down Expand Up @@ -235,9 +234,6 @@ async def _start(self):
else:
ForestLogger.log("warning", 'Schema update was skipped (caused by options["skip_schema_update"]=True)')

for collection in (await self.customizer.get_datasource()).collections:
create_json_api_schema(collection)

if self.options["instant_cache_refresh"]:
self._sse_thread.start()

Expand Down
Loading