Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Searching by set #445

Open
1 of 5 tasks
Tracked by #45
fakeheal opened this issue Jun 23, 2023 · 3 comments
Open
1 of 5 tasks
Tracked by #45

enhancement: Searching by set #445

fakeheal opened this issue Jun 23, 2023 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@fakeheal
Copy link

Data affected

  • Card
  • Set
  • Serie
  • Other
  • new Data Type

Please explain in more details what idea you have

Hi,

I want to add filters for searching cards based on sets. I am wondering which approach is better so I'd love some input.

Approach 1:

# Filters to be used with the Card query
input CardsFilters {
        # ...
	setId: String
        setName: String
       # other set properties
}

and then in Cards.ts:

public static find(lang: SupportedLanguages, params: Partial<Record<keyof SDKCard, any>> = {}, pagination?: Pagination) {
	// ....
	.filter((c) => {
		return objectLoop(params, (it, key) => {
			if(key == 'setId') {
				return c.set.id === it; // new line, same for all other set properties
			}
			return lightCheck(c[key as 'localId'], it)
		});
	})
	// ....
}

Approach 2:

# Filters to be used with the Card query
input CardsFilters {
        # ...	
	set: CardsFiltersSet
}

input CardsFiltersSet {
	id: String
	name: String
	tcgOnline: String
	releaseDate: String
	symbol: String
}

and then in Cards.ts:

public static find(lang: SupportedLanguages, params: Partial<Record<keyof SDKCard, any>> = {}, pagination?: Pagination) {
	// ...
	.filter((c) => {
		return objectLoop(params, (it, key) => {
                        // vvvv new code starts here vvvv
			if(key === 'set') {
				return objectLoop(it, (nestedIt, nestedKey) => {
					return lightCheck(
						c[key as 'set'][nestedKey as 'id' | 'name'],
						nestedIt
					);
				})
			}
                        // ^^^ new code starts here ^^^
		});
	})
	// ...
}

I have no idea why everything in the code snippets (ts) is so indented...

@fakeheal fakeheal added the enhancement New feature or request label Jun 23, 2023
@Aviortheking
Copy link
Member

Hi, sorry for the big delay, the second implementation seems to me to be a better one ! if you can test it and implement it it would be awesome !

@fakeheal
Copy link
Author

No worries! I will do that in the upcoming weeks.

@Aviortheking
Copy link
Member

Hey, I did some edits to implement new features set for the server, I also made some more place to simplify filtering, it should be easier to implement now, let me know if you need anything !

@Aviortheking Aviortheking mentioned this issue May 7, 2024
21 tasks
@Aviortheking Aviortheking added this to the 2.0 milestone May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants