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

feat: add function for number of rows filtered #56

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

khareyash05
Copy link
Contributor

@khareyash05 khareyash05 commented Mar 26, 2024

Fixes #19

Working Filter functionality


Ellipsis 🚀 This PR description was created by Ellipsis for commit 96f5c65.

Summary:

This PR adds a new feature that displays the number of rows filtered, achieved by updating the FilterBlock component and creating a new worker for the calculation, and includes the addition of comlink dependency.

Key points:

  • Added comlink dependency in package.json
  • Updated FilterBlock component in /src/components/FilterBlock.tsx to include logic for calculating and displaying the number of rows filtered
  • Created a new worker in /src/components/worker.ts for calculating the number of rows filtered

Generated with ❤️ by ellipsis.dev

@khareyash05 khareyash05 marked this pull request as ready for review March 28, 2024 07:51
@khareyash05
Copy link
Contributor Author

Ready for review @ramonverse

@@ -60,6 +61,7 @@ const Filter: React.FC<FilterProps> = ({
query,
}) => {
const [fieldValues, setFieldValues] = useState<string[]>([])
const [val,setVal] = useState(0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to rowsFiltered, setRowsFiltered

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that!

setFieldValue={(value) => onFilterChange({ ...filter, value })}
setFieldValue={(value) => {
onFilterChange({ ...filter, value })
filter.value=value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't assign values to a property

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove it when I had been testing. Will remove that!

src/lib/utils.ts Outdated
// SQL
// return `select * from table where (${filter}) (${operator}) (${value})`
// PRQL
if(filter && operator){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these logic is duplicated here and in filterblock. You could create a utils function like this to avoid bugs and duplications:

export const getPrqlFilter = (operator: string): string => { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am getting this correct, is it like this


export const getPrqlFilter = (operator:string):string =>{
  if(operator=='equals'){
    return `==`
  }
  if(operator=='notEquals'){
    return `!=`
  }
  if(operator=='contains'){
    return `std.text.contains this.`
  }
  return ""
}

@khareyash05
Copy link
Contributor Author

Converting to draft PR, need to handle grouping of filters before reviewing

@khareyash05 khareyash05 marked this pull request as draft March 30, 2024 11:30
@khareyash05
Copy link
Contributor Author

Filter functionality now works for individual filters

@khareyash05 khareyash05 marked this pull request as ready for review April 2, 2024 07:16
@khareyash05
Copy link
Contributor Author

Ready for review @ramonverse

@ramonverse
Copy link
Collaborator

Hi @khareyash05 , unfortunately this blocks the main thread for larger files and the UX is terrible. This feature probably needs to be implemented with a web-worker in order to work ok in the browser.

@khareyash05
Copy link
Contributor Author

khareyash05 commented Apr 2, 2024

Hi @khareyash05 , unfortunately this blocks the main thread for larger files and the UX is terrible. This feature probably needs to be implemented with a web-worker in order to work ok in the browser.

Understood. Are we looking for pushing this task to asynchronous processing? I do have an idea around the same?would love to work on the idea, if it isn't in an immediate need. Thanks

Also it would be great to hear your ideas on the same. Would help me get a direction

@ramonverse
Copy link
Collaborator

@khareyash05 I'd say make a web-worker with comlink https://github.com/GoogleChromeLabs/comlink that just calculates the rows. Also save the previous rows in a state so we can show it like this in the UI: `${prevRowCount} -> ${currentRowCount)}`

@khareyash05
Copy link
Contributor Author

@khareyash05 I'd say make a web-worker with comlink https://github.com/GoogleChromeLabs/comlink that just calculates the rows. Also save the previous rows in a state so we can show it like this in the UI: ${prevRowCount} -> ${currentRowCount)}

On it!

@khareyash05
Copy link
Contributor Author

@ellipsis-dev review

Copy link

ellipsis-dev bot commented Apr 9, 2024

OK! Reviewing this PR...


Responding to this comment by @khareyash05. For more information about Ellipsis, check the documentation.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested.

  • Reviewed the entire pull request up to 96f5c65
  • Looked at 127 lines of code in 3 files
  • Took 2 minutes and 29 seconds to review
More info
  • Skipped 1 files when reviewing.
  • Skipped posting 0 additional comments because they didn't meet confidence threshold of 50%.

Workflow ID: wflow_TjcqQkdghQkePVVq


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. We'll respond in a few minutes. Learn more here.

src/components/FilterBlock.tsx Show resolved Hide resolved
import * as Comlink from 'comlink'

export class FilterRowCount{
async findFilteredRowCount(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider passing the necessary arguments directly to the worker method instead of passing a function. This could help avoid potential issues if the function signature changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khareyash05 want to addreess this?

src/components/worker.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload and Filterblock shoul include total row information
2 participants