Open rowanseymour opened 8 years ago
In which Files of rapidPro can i add the function WEEKNUM??
Java implementation goes in https://github.com/rapidpro/expressions/blob/master/java/src/main/java/io/rapidpro/expressions/functions/ExcelFunctions.java Java tests go in https://github.com/rapidpro/expressions/blob/master/java/src/test/java/io/rapidpro/expressions/functions/ExcelFunctionsTest.java Python implementation goes in https://github.com/rapidpro/expressions/blob/master/python/temba_expressions/functions/excel.py Python tests go in https://github.com/rapidpro/expressions/blob/master/python/temba_expressions/tests.py Cross-language tests go in https://github.com/rapidpro/expressions/blob/master/common/template_tests.json
@rowanseymour thank you very much. I will add it with java implementation
@rowanseymour I don't find these files on rapidPro. I must install them with command ?
This is separate library which we import into RapidPro.
Remember you need to implement it in both Java and Python - then add tests to show that they are consistent with each other, and consistent with Excel itself.
OK. I install openjdk and now di i put ExcelFunctions.java in rapidpro/expressions/functions/ folder? Also if i add new function i can just call it with @(NEW_FUNCTION()) ?
Look at the existing functions in ExcelFunctions.java and follow the same pattern. If you create a method called new_function
you will be able to call it like @(NEW_FUNCTION())
I don't find ExcelFunctions.java in my RapidPro. I just find excels.py in /env/lib/python2.7/site-packages/expressions/functions folder. Do i import in that folder or in another folder?
It's not in RapidPro - it's in this repo that this issue belongs to. This is a project which contains the Java implementation of the RapidPro expression engine (used by Surveyor) and the Python implementation (used by the RapidPro Django app)
Thank you. I finally add WEEKNUM function but in python. This is the function and it works fine
def weeknum(ctx, date): """ Returns the num of the week of a date (Between 1 and 52) """ return (conversions.to_date_or_datetime(date, ctx).isocalendar()[1])
Hello @rowanseymour. The function run in the simulator without error but if i test the flow with a phone i get @(WEEKNUM(TODAY())) instead of 4 for example
How can i test my need function just added in my copy of expressions lib ?
See https://support.office.com/en-us/article/WEEKNUM-function-e5c43a03-b4ab-426c-b411-b18c13c75340