Use datum filter everywhere
Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<453e3cd4a7a9fdbacd183d097ec95a05>>
|
* @generated SignedSource<<7e67f2a3d41fbea46b7b8447595302a5>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -316,7 +316,6 @@ return {
|
|||||||
"alias": null,
|
"alias": null,
|
||||||
"args": (v5/*: any*/),
|
"args": (v5/*: any*/),
|
||||||
"filters": [
|
"filters": [
|
||||||
"orderBy",
|
|
||||||
"filter"
|
"filter"
|
||||||
],
|
],
|
||||||
"handle": "connection",
|
"handle": "connection",
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const paginatedDataFragment = graphql`
|
|||||||
before: $before
|
before: $before
|
||||||
orderBy: $order
|
orderBy: $order
|
||||||
filter: { snapshotId: $snapshotId }
|
filter: { snapshotId: $snapshotId }
|
||||||
) @connection(key: "DataPage_data") {
|
) @connection(key: "DataPage_data", filters: ["filter"]) {
|
||||||
__id
|
__id
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
|||||||
@@ -59,7 +59,11 @@ export default function DatumDetailsPage(props: Props) {
|
|||||||
|
|
||||||
const deleteDatum = useDeleteDatum(
|
const deleteDatum = useDeleteDatum(
|
||||||
datumEntry,
|
datumEntry,
|
||||||
ConnectionHandler.getConnectionID(organizationId, "DataPage_data"),
|
ConnectionHandler.getConnectionID(
|
||||||
|
organizationId,
|
||||||
|
"DataPage_data",
|
||||||
|
{ filter: { snapshotId: snapshotId || null } }
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const vendors = datumEntry?.vendors?.edges.map(edge => edge.node) ?? [];
|
const vendors = datumEntry?.vendors?.edges.map(edge => edge.node) ?? [];
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<8364d9457b59a3ef50b508ab55991638>>
|
* @generated SignedSource<<2000fd2ccfcf4b832c51ff71b0326fef>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -394,7 +394,6 @@ return {
|
|||||||
"alias": null,
|
"alias": null,
|
||||||
"args": (v15/*: any*/),
|
"args": (v15/*: any*/),
|
||||||
"filters": [
|
"filters": [
|
||||||
"orderBy",
|
|
||||||
"filter"
|
"filter"
|
||||||
],
|
],
|
||||||
"handle": "connection",
|
"handle": "connection",
|
||||||
@@ -422,6 +421,6 @@ return {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(node as any).hash = "a60d9b34a83df89eb59ffcd359903ce8";
|
(node as any).hash = "5d3069a0d856613ccb854033b5b1f14e";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @generated SignedSource<<17f6d8607b6d2a1b575e1251019b8375>>
|
* @generated SignedSource<<9619ee8f74aea67be931f8c40a8815c8>>
|
||||||
* @lightSyntaxTransform
|
* @lightSyntaxTransform
|
||||||
* @nogrep
|
* @nogrep
|
||||||
*/
|
*/
|
||||||
@@ -143,11 +143,6 @@ return {
|
|||||||
],
|
],
|
||||||
"kind": "ObjectValue",
|
"kind": "ObjectValue",
|
||||||
"name": "filter"
|
"name": "filter"
|
||||||
},
|
|
||||||
{
|
|
||||||
"kind": "Variable",
|
|
||||||
"name": "orderBy",
|
|
||||||
"variableName": "order"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"concreteType": "DatumConnection",
|
"concreteType": "DatumConnection",
|
||||||
@@ -334,6 +329,6 @@ return {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
(node as any).hash = "a60d9b34a83df89eb59ffcd359903ce8";
|
(node as any).hash = "5d3069a0d856613ccb854033b5b1f14e";
|
||||||
|
|
||||||
export default node;
|
export default node;
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ func (d *Data) CountByOrganizationID(
|
|||||||
conn pg.Conn,
|
conn pg.Conn,
|
||||||
scope Scoper,
|
scope Scoper,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
|
filter *DatumFilter,
|
||||||
) (int, error) {
|
) (int, error) {
|
||||||
q := `
|
q := `
|
||||||
SELECT
|
SELECT
|
||||||
@@ -162,12 +163,14 @@ FROM
|
|||||||
WHERE
|
WHERE
|
||||||
%s
|
%s
|
||||||
AND organization_id = @organization_id
|
AND organization_id = @organization_id
|
||||||
|
AND %s
|
||||||
`
|
`
|
||||||
|
|
||||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
q = fmt.Sprintf(q, scope.SQLFragment(), filter.SQLFragment())
|
||||||
|
|
||||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||||
maps.Copy(args, scope.SQLArguments())
|
maps.Copy(args, scope.SQLArguments())
|
||||||
|
maps.Copy(args, filter.SQLArguments())
|
||||||
|
|
||||||
row := conn.QueryRow(ctx, q, args)
|
row := conn.QueryRow(ctx, q, args)
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ func (s DatumService) GetByOwnerID(
|
|||||||
func (s DatumService) CountForOrganizationID(
|
func (s DatumService) CountForOrganizationID(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
organizationID gid.GID,
|
organizationID gid.GID,
|
||||||
|
filter *coredata.DatumFilter,
|
||||||
) (int, error) {
|
) (int, error) {
|
||||||
var count int
|
var count int
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ func (s DatumService) CountForOrganizationID(
|
|||||||
ctx,
|
ctx,
|
||||||
func(conn pg.Conn) (err error) {
|
func(conn pg.Conn) (err error) {
|
||||||
data := coredata.Data{}
|
data := coredata.Data{}
|
||||||
count, err = data.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID)
|
count, err = data.CountByOrganizationID(ctx, conn, s.svc.scope, organizationID, filter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot count data: %w", err)
|
return fmt.Errorf("cannot count data: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ type (
|
|||||||
|
|
||||||
Resolver any
|
Resolver any
|
||||||
ParentID gid.GID
|
ParentID gid.GID
|
||||||
|
Filter *DatumFilter
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,6 +38,7 @@ func NewDataConnection(
|
|||||||
p *page.Page[*coredata.Datum, coredata.DatumOrderField],
|
p *page.Page[*coredata.Datum, coredata.DatumOrderField],
|
||||||
parentType any,
|
parentType any,
|
||||||
parentID gid.GID,
|
parentID gid.GID,
|
||||||
|
filter *DatumFilter,
|
||||||
) *DatumConnection {
|
) *DatumConnection {
|
||||||
edges := make([]*DatumEdge, len(p.Data))
|
edges := make([]*DatumEdge, len(p.Data))
|
||||||
for i, datum := range p.Data {
|
for i, datum := range p.Data {
|
||||||
@@ -49,6 +51,7 @@ func NewDataConnection(
|
|||||||
|
|
||||||
Resolver: parentType,
|
Resolver: parentType,
|
||||||
ParentID: parentID,
|
ParentID: parentID,
|
||||||
|
Filter: filter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -558,7 +558,12 @@ func (r *datumConnectionResolver) TotalCount(ctx context.Context, obj *types.Dat
|
|||||||
|
|
||||||
switch obj.Resolver.(type) {
|
switch obj.Resolver.(type) {
|
||||||
case *organizationResolver:
|
case *organizationResolver:
|
||||||
count, err := prb.Data.CountForOrganizationID(ctx, obj.ParentID)
|
datumFilter := coredata.NewDatumFilter(nil)
|
||||||
|
if obj.Filter != nil {
|
||||||
|
datumFilter = coredata.NewDatumFilter(&obj.Filter.SnapshotID)
|
||||||
|
}
|
||||||
|
|
||||||
|
count, err := prb.Data.CountForOrganizationID(ctx, obj.ParentID, datumFilter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, fmt.Errorf("cannot count data: %w", err)
|
return 0, fmt.Errorf("cannot count data: %w", err)
|
||||||
}
|
}
|
||||||
@@ -3672,7 +3677,7 @@ func (r *organizationResolver) Data(ctx context.Context, obj *types.Organization
|
|||||||
panic(fmt.Errorf("cannot list organization data: %w", err))
|
panic(fmt.Errorf("cannot list organization data: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return types.NewDataConnection(page, r, obj.ID), nil
|
return types.NewDataConnection(page, r, obj.ID, filter), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audits is the resolver for the audits field.
|
// Audits is the resolver for the audits field.
|
||||||
|
|||||||
Reference in New Issue
Block a user