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(front): Implement front-end for replacetext step TCTC-4368 #1556

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

lukapeschke
Copy link
Contributor

TCTC-4368

TCTC-4368

Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
@lukapeschke lukapeschke added enhancement New feature or request need review labels Oct 26, 2022
@lukapeschke lukapeschke self-assigned this Oct 26, 2022
@render
Copy link

render bot commented Oct 26, 2022

Copy link
Member

@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

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

Otherwise looks good!

from weaverbird.pipeline.steps.utils.render_variables import StepWithVariablesMixin
from weaverbird.pipeline.types import ColumnName, TemplatedVariable


class ReplaceTextStep(BaseStep):
class Config:
alias_generator = to_camelcase
Copy link
Member

Choose a reason for hiding this comment

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

isn't it something we should have by default on all base steps ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, but It'll probably be a breaking change. I'm preparing another PR for that, to be merged after the LTS branches have been created

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oldStr: {
type: 'string',
description: 'String to replace',
minLength: 1,
Copy link
Member

Choose a reason for hiding this comment

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

Why min length? If I want to replace empty strings with something else

Copy link
Contributor Author

@lukapeschke lukapeschke Oct 27, 2022

Choose a reason for hiding this comment

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

Then you'd use the normal already existing replace step, which replaces values

Copy link
Member

Choose a reason for hiding this comment

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

I don't know the codebase as well as you but from a user perspective it makes no sense to have two different steps if I want to replace '' or 'a'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first, we were wondering if replacing text and values should both be done in the same step or not. After discussion with product, we've decided to to it in two separate steps.

The difference between the two steps is:

  • I want to replace all values in column col containing the literal value "a" with 42 -> that's a replace, the type can change. Only cells with "a" in them will be modified -> Cells with "baba" are left untouched.
  • In my string columns, I want to replace the string "guys" with "people" -> That's a replacetext. All cells containing "guys" will be modified: "guys" will become "people", "hello guys" will become "hello people".

In your example the expeected behaviour of a replacetext("", "a") would be "foo" -> "afaoaoa", which is probably not what the end user wants

Copy link
Member

Choose a reason for hiding this comment

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

Ok got it thanks a lot

Copy link
Contributor

Choose a reason for hiding this comment

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

Too bad it wasn't called "replace substring"
I didn't realize what this would do until I read your last example 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, naming is a bit frustrating for devs, but with product we thought that it was better to have "text" everywhere rather than let end users figure out by themselves wtf a "substring" is supposed to be 😄

Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
@codecov
Copy link

codecov bot commented Oct 27, 2022

Codecov Report

Base: 98.43% // Head: 98.44% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (2d873af) compared to base (1b679b8).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1556   +/-   ##
=======================================
  Coverage   98.43%   98.44%           
=======================================
  Files         216      218    +2     
  Lines        6138     6167   +29     
  Branches      961      962    +1     
=======================================
+ Hits         6042     6071   +29     
  Misses         96       96           
Impacted Files Coverage Δ
weaverbird/src/lib/steps.ts 100.00% <0.00%> (ø)
weaverbird/src/components/constants.ts 100.00% <0.00%> (ø)
weaverbird/src/components/stepforms/index.ts 100.00% <0.00%> (ø)
...averbird/src/components/stepforms/schemas/index.ts 100.00% <0.00%> (ø)
...d/src/components/stepforms/ReplaceTextStepForm.vue 100.00% <0.00%> (ø)
...rd/src/components/stepforms/schemas/replaceText.ts 100.00% <0.00%> (ø)
weaverbird/src/lib/translators/base.ts 98.86% <0.00%> (+0.01%) ⬆️
weaverbird/src/lib/templating.ts 97.89% <0.00%> (+0.01%) ⬆️
weaverbird/src/lib/labeller.ts 97.93% <0.00%> (+0.02%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@lukapeschke lukapeschke merged commit a61404e into master Oct 27, 2022
@lukapeschke lukapeschke deleted the frontend-replacetext-step branch October 27, 2022 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants