pepsico-ecommerce / chore_runner Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
Hey Chris & co,
Love the library and have found it invaluable to create custom one-off admin job tooling with papertrail and the likes baked in.
One little feature idea we had recently was to make it possible to pass in chore input values via URL query string params, as this would allow us to set up nicely deep-linked shortcuts to open a chore from another admin page with some job details pre-filled.
Example use-case:
If we have some admin page with a list of users, and need to run a one-off chore for a particular user, amazing to be able to link to the relevant chore job with the user's id input argument pre-filled in the chore, to avoid us making one-off copy-pasta mistakes when running the job.
Would be great to be able to opt-in as part of the chore inputs
options DSL, which ones we want to be pre-fillable via query parameter.
Then from the chore URL in the route, the values for those inputs could be pre-filled based on the decoded corresponding query param from the URL.
Concrete example, say I have a chore called TopupUserPointsBalance
and it takes a user_id
as one of its inputs.
In the inputs DSL I could specify eg (placeholder name proposal of a new allow_query_param
option to specify opt-in to this behavior, although I personally wouldn't mind if it was default supported for all input fields that are expressible in query params!):
def inputs,
do: [
string(:user_id, validators: [&check_user_id/1], allow_query_param: true),
]
Then say my chore runner route is specified as /chores/
, I could visit this URL then to have the user_id
input pre-filled on the job:
/chores?chore=TopupUserPointsBalance&user_id=the_user_id
to have the_user_id
prefilled in the user_id
input field.
Thanks & LMK if you / others would see value in this addition!
Understand the project cannot take PRs directly due to licensing/corporate constraints, but would still be happy to contribute a reference PR if this would be helpful.
Think possible to keep the changes very narrowly scoped with a small helper fn addition to ChoreLive
and the Input.input_options
spec.
All the best & thanks again for sharing this project with the broader community,
Ethan
First of all, thanks for the library, it's awesome!
I watched your talk on ElixirConf 2021 and I was amazed. Fortunately, I got a chance to give it a try now.
However, when I followed the README document and my input definition doesn't work.
My module is quite simple:
defmodule MyApp.Chores.MyChore do
use ChoreRunner.Chore
def input do
[
string(:platform)
]
end
def run(inputs) do
log(["hi, I'm running, inputs:", inspect(inputs)])
:ok
end
end
An input form that allows me to enter some text.
The input form in the UI is empty and the logged inputs
value is always %{}
.
After some digging, I found that actually, the function name should be inputs (plural form).
I changed the name to inputs and it now works.
So, I think in the README, it should be inputs/0
instead of input/0
, and we can add @impl true
before these callback functions so that the compiler can help validate the names.
Thanks!
Currently it is not possible to install chore_runner on latest phoenix projects.
Any plans to update it?
Hey,
The dep seems great, but it uses and older live_view version.
Any chance to support newer versions?
I added override: true
to my phoenix_live_view
dep, which allows me to install chore_runner, but compilation fails.
warning: passing a string as a layout template in use options is deprecated, please pass an atom, such as :live instead of "live.html"
(phoenix_live_view 0.18.3)
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.