Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ammaaraslam committed Aug 10, 2022
2 parents ec00de8 + 30636fa commit 631cb9a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 94 deletions.
133 changes: 41 additions & 92 deletions src/common/services/request/query/fetch-plays-filter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BasiFetchParam } from "./fetch-plays";

const env = process.env.NODE_ENV === "development";
const preview = process.env.REACT_APP_PREVIEW_MODE;
const defaultClause = {
Expand All @@ -11,83 +13,48 @@ export const FetchPlaysFilter = {
// Filter all the featured plays
getAllFeaturedPlays() {
return {
display: "Filter all the featured plays",
name: "Fetch_Plays",
function: "plays",
return: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
{ play_like: ["liked", "play_id", "user_id"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
clause: {
operator: "and",
conditions: [
defaultClause,
{
field: "featured",
operator: "eq",
value: true,
},
],
...BasiFetchParam,
...{
display: "Filter all the featured plays",
where: {
clause: {
operator: "and",
conditions: [
defaultClause,
{
field: "featured",
operator: "eq",
value: true,
},
],
},
},
},
};
},
// Filter Plays by a search string in name or description
filterPlaysBySearchString(Obj) {
return {
display: "Filter Plays by a search string in name or description",
name: "Fetch_Plays",
function: "plays",
return: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
{ play_like: ["liked", "play_id", "user_id"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
where: {
clause: {
operator: "or",
conditions: [
{
field: "name",
operator: "iregex",
value: Obj.name.toLowerCase(),
},
{
field: "description",
operator: "iregex",
value: Obj.name.toLowerCase(),
},
],
...BasiFetchParam,
...{
display: "Filter Plays by a search string in name or description",

where: {
clause: {
operator: "or",
conditions: [
{
field: "name",
operator: "iregex",
value: Obj.name.toLowerCase(),
},
{
field: "description",
operator: "iregex",
value: Obj.name.toLowerCase(),
},
],
},
},
},
};
Expand All @@ -100,28 +67,10 @@ export const FetchPlaysFilter = {
*/
filterPlaysByMultiTagsLevelLang(Obj) {
const payload = {
display: "Filter plays by level, user, language, and multiple tags",
name: "Fetch_Plays",
function: "plays",
return: [
"blog",
"component",
"cover",
"created_at",
"description",
"featured",
"github",
"id",
"language",
{ level: ["name"] },
{ play_like: ["liked", "play_id", "user_id"] },
"name",
"path",
{ play_tags: { tag: ["name"] } },
"updated_at",
{ user: ["id", "displayName", "avatarUrl"] },
"video",
],
...BasiFetchParam,
...{
display: "Filter plays by level, user, language, and multiple tags",
},
};

const clause = {
Expand Down
4 changes: 2 additions & 2 deletions src/common/services/request/query/fetch-plays.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function FetchPlaysBySlugAndUser(playslug, username) {
return payload;
}

const BasiFetchParam = {
export const BasiFetchParam = {
display: "Simple fetch play",
name: "Fetch_Plays",
function: "plays",
Expand All @@ -64,7 +64,7 @@ const BasiFetchParam = {
],
};

const DetailedFetchParam = {
export const DetailedFetchParam = {
...BasiFetchParam,
...{
return: [
Expand Down

0 comments on commit 631cb9a

Please sign in to comment.