vanus icon indicating copy to clipboard operation
vanus copied to clipboard

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

Open Michaelg22 opened this issue 2 years ago • 12 comments

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 avatar Feb 25 '23 06:02 Michaelg22

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

Michaelg22 avatar Feb 25 '23 06:02 Michaelg22

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

kbavi avatar Feb 25 '23 08:02 kbavi

Thanks I will assign it to you!

Michaelg22 avatar Feb 25 '23 09:02 Michaelg22

the time format is Y-m-d

xdlbdy avatar Feb 25 '23 11:02 xdlbdy

Should we add an argument to change it @xdlbdy

Michaelg22 avatar Feb 25 '23 11:02 Michaelg22

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

Michaelg22 avatar Feb 25 '23 11:02 Michaelg22

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.

kbavi avatar Feb 25 '23 12:02 kbavi

I have changed the description of targetJSONPath

xdlbdy avatar Feb 27 '23 01:02 xdlbdy

Please I'd love to work on this

c0d33ngr avatar Apr 03 '23 12:04 c0d33ngr

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

shashank-mishra14 avatar Apr 15 '23 18:04 shashank-mishra14

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

amribm avatar Jul 22 '23 15:07 amribm

hi @AmeerIbrahimm I assign it to you.

Michaelg22 avatar Jul 24 '23 00:07 Michaelg22