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

[Good First Issues]: implement function "today" - 4 points #462

Open
Tracked by #355
Michaelg22 opened this issue Feb 25, 2023 · 12 comments · May be fixed by #464 or #616
Open
Tracked by #355

[Good First Issues]: implement function "today" - 4 points #462

Michaelg22 opened this issue Feb 25, 2023 · 12 comments · May be fixed by #464 or #616
Assignees
Labels
good first issue help-wanted Extra attention is needed

Comments

@Michaelg22
Copy link
Contributor

Michaelg22 commented Feb 25, 2023

Motivation

Vanus Functions are a series of pre-built functions worked within Vanus transformer. By choosing a function, users can specify the way that events will be changed.

It will be a good start if you decide to contribute to Vanus codes.

Details

Function name: today

Args

  • targetJsonPath - The name of the new path to be created.
  • timeZone - Optional. The name of the country and city. If no time zone is specified, then the default is Universal Coordinated Time (UTC).

Description

The function is used to get the current date(format: YYYY-MM-DD) in a specific TimeZone. And assign it to the target JSON path.
The Time Zone will be UTC if users don't specify it.

Example

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "subject": null,
    "id" : "C234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "application/json",
    "data" : {
        appinfoA : "Hello world",
       

    }
}

After the function.

"pipeline":[
    {"command":["today","$.data.time", "Europe/Madrid"]}
]

The transformed event should look like this:

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "subject": null,
    "id" : "C234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "application/json",
    "data" : {
        appinfoA : "Hello world",
        time : "2023-01-12"

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-today
  3. Create today.go under internal/primitive/transform/action/datatime, and then implement the function.
  4. Create today.go under internal/primitive/transform/action/datatime for unit test.
  5. Register your function in internal/primitive/transform/runtime/init.go.
  6. Submit your PR

Contribution points

Each issue counts specific points based on its difficulty. Contributors earn the corresponding points if they solve that issue. Contribution points are used to describe the contributions contributors have made. They can also be used to get rewards when there are community events.

This issue counts 4 points.

How to claim to solve the issue

If you want to implement this function, please leave a comment in this issue like:

I'd like to implement this function, please assign this issue to me.

Vanus community will assign the issue to you on time.

@Michaelg22
Copy link
Contributor Author

Looking for a new person to contribute to this issue. :)

@kbavi
Copy link

kbavi commented Feb 25, 2023

@Michaelg22 hey, I would like to work on this issue.

@Michaelg22
Copy link
Contributor Author

Thanks I will assign it to you!

@kbavi kbavi linked a pull request Feb 25, 2023 that will close this issue
4 tasks
@xdlbdy
Copy link
Contributor

xdlbdy commented Feb 25, 2023

the time format is Y-m-d

@Michaelg22
Copy link
Contributor Author

Should we add an argument to change it @xdlbdy

@Michaelg22
Copy link
Contributor Author

y-m-d or d-m-y and m-d-y ...

@kbavi
Copy link

kbavi commented Feb 25, 2023

targetJsonPath - The name of an existing column

The provided example {"command":["today","$.data.time", "Europe/Madrid"]} works on the event where the data map does not have a time column as suggested by $.data.time.
@Michaelg22 can you please clarify the requirement or help me understand if I am missing something.

@xdlbdy
Copy link
Contributor

xdlbdy commented Feb 27, 2023

I have changed the description of targetJSONPath

@c0d33ngr
Copy link
Contributor

c0d33ngr commented Apr 3, 2023

Please I'd love to work on this

@shashank-mishra14
Copy link

Hey, Please assign this issue to me, I want to work on this too.

@AmeerIbrahimm
Copy link

hey, please assign it to me. i will love to work on this.

@Michaelg22
Copy link
Contributor Author

hi @AmeerIbrahimm I assign it to you.

@AmeerIbrahimm AmeerIbrahimm linked a pull request Aug 17, 2023 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue help-wanted Extra attention is needed
Projects
None yet
6 participants