Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TejasShekar committed Jun 20, 2022
2 parents b70763c + 756bf39 commit 5b94372
Show file tree
Hide file tree
Showing 7 changed files with 737 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"postbuild": "react-snap",
"snap": "react-snap",
"test": "react-scripts test",
"eject": "react-scripts eject",
"create-play": "plop"
Expand Down
1 change: 1 addition & 0 deletions src/common/services/request/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Will remove this directory once the API stabilizes
271 changes: 271 additions & 0 deletions src/common/services/request/example/fetch-plays-filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
export const FetchPlaysFilter = [
// Filter all the featured plays
{
display: "Filter all the featured plays",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "",
clause: [
{
field: "featured",
operator: "eq",
value: true,
type: "boolean",
},
],
},
},
// Filter Plays by a search string in name or description
{
display: "Filter Plays by a search string in name or description",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "or",
clause: [
{
field: "name",
operator: "iregex",
value: "why",
type: "string",
},
{
field: "description",
operator: "iregex",
value: "why",
type: "string",
},
],
},
},
// Filter Plays by Level
{
display: "Filter Plays by Level",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "",
class: "level",
clause: [
{
field: "name",
operator: "eq",
value: "Advanced",
type: "string",
},
],
},
},
// Alternatively using the id
{
display: "Alternatively using the id",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "",
clause: [
{
field: "level_id",
operator: "eq",
value: "2af38a32-37a7-4456-b21b-bf6b3aedd804",
type: "string",
},
],
},
},
// Filter plays by level, user and language
{
display: "Filter plays by level, user and language",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{
play_tags: { tag: ["name"] },
},
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "and",
clause: [
{
field: "owner_user_id",
operator: "eq",
value: "0680f581-6584-4bc4-bbe9-aa7c97567e72",
type: "string",
},
{
field: "level_id",
operator: "eq",
value: "4127ed16-bf37-4c34-bed0-282cd646cd53",
type: "string",
},
{
field: "language",
operator: "eq",
value: "js",
type: "string",
},
],
},
},
// Filter plays by level, user, language, and multiple tags
{
display: "Filter plays by level, user, language, and multiple tags",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{
play_tags: { tag: ["name"] },
where: {
operator: "or",
class: "tag",
clause: [
{
field: "name",
operator: "eq",
value: "JSX",
type: "string",
},
{
field: "name",
operator: "eq",
value: "Schedule",
type: "string",
},
],
},
},
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "and",
clause: [
{
field: "owner_user_id",
operator: "eq",
value: "0680f581-6584-4bc4-bbe9-aa7c97567e72",
type: "string",
},
{
field: "level_id",
operator: "eq",
value: "4127ed16-bf37-4c34-bed0-282cd646cd53",
type: "string",
},
{
field: "language",
operator: "eq",
value: "js",
type: "string",
},
],
},
},
];
47 changes: 47 additions & 0 deletions src/common/services/request/example/fetch-plays-paginated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export const FetchPlaysPaginated = [
{
display: "Paginated play view",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
operator: "",
clause: [
{
field: "featured",
operator: "eq",
value: true,
type: "boolean",
},
],
},
filters: [
{
field: "offset",
value: 1,
},
{
field: "limit",
value: 4,
},
],
},
];
32 changes: 32 additions & 0 deletions src/common/services/request/example/fetch-plays-sorted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export const FetchPlaysSorted = [
{
display: "Sorted play view",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
orders: [
{
field: "created_at",
value: "asc",
},
],
},
];
26 changes: 26 additions & 0 deletions src/common/services/request/example/fetch-plays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export const FetchPlaysSimple = [
{
display: "Simple fetch play",
name: "Fetch_Plays",
function: "plays",
write: false,
params: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
},
];
Loading

0 comments on commit 5b94372

Please sign in to comment.