Fork me on GitHub
#beginners
<
2024-03-02
>
leifericf08:03:55

I have many users creating rather sophisticated application data using Excel with a custom plugin written in C#, which leads to all of the classical problems of using Excel as a multi-user business application at scale. I want to replace these Excel sheets with a tool, whether a desktop or web application, with greater data validation control, versioning (free with Datomic), resolving conflicting edits, etc. One of the features it must support is applying custom formulas to multiple values on these "data entities” (currently several rows in different sheets) to create new calculated values (currently columns). Is anyone aware of some approaches or Clojure libraries that might be useful for implementing user-defined formulas language within their Clojure application? I'm considering embedding SCI or Babashka, but I'm afraid the Lisp syntax is too foreign for my semi-technical users. It might be better to use something more similar to Excel-style functions, where the users could chain them together in a way that is more familiar to them.

phill11:03:32

The formula syntax is the very least of your problems. You can write your own, use Java's embeddable script engine capability and plug in GraalVM's JavaScript, shell out to Perl, etc.

leifericf12:03:03

It seemed like the most challenging part to me. If “user-defined calculated fields” are the least of my problems, what is the most challenging aspect in your mind? 😅

phill16:03:59

Mostly in jest. But someone who is mildly dissatisfied with a complex monster of over-clocked Excel might be difficult to please. If at all possible, you could have them hire and fire another consultant before you heroically step in with a solution. As to that solution, the foundation is data which you will need to model in space and time. The offhand reference to versioning (free with Datomic) made me think this modeling might not yet be complete. 🙂

😅 1
Joseph Graham08:03:22

I keep getting these namespaced maps back from my database queries (using seancorfield/next-jdbc). It there a way to strip off the namespace so I can simply access it using the short keyword?

#:apppage{:page_id 2, :page_name "testing", :order_key 5, :page_type "task"}

Joseph Graham09:03:16

wow thanks. I was looking for a solution at the clojure level, didn't realise I can configure the driver

daveliepmann09:03:10

One Clojure-level solution would be something like

(update-keys #:apppage{:page_id 2, :page_name "testing", :order_key 5, :page_type "task"}
             #(keyword nil (name %)))

;; => {:order_key 5, :page_id 2, :page_name "testing", :page_type "task"}

Joseph Graham09:03:11

ah, nice!

👍 1
seancorfield17:03:16

Why do you want to strip the namespace? The default is that way for a reason: qualified keys are good - they help avoid collisions between, say, :person/id and :address/id. You can use aliases to make them shorter to type if you really can't bear typing a few extra characters for the table name:grin:

Joseph Graham17:03:48

I always avoid calling any columns "id" for that exact reason. I use <tablename>_id instead.

seancorfield21:03:21

I find that too repetitive in joins: join foo on foo.foo_id = bar.foo_id but I've seen both styles in dba recommendations over the years...

seancorfield21:03:47

... And mapping :foo/id to foo.id is what I'm used to from HoneySQL, rather than :foo/foo-id

Felipe16:03:00

if you name your columns like that you can use both USING and NATURAL, so it doesn’t need to be repetitive :) I don’t do this though, just offering it as trivia instead of recommending the approach

1
Akane14:03:04

hi everyone! i am planning to generate some snowflake IDs, do anyone know some good libraries for doing just that? every native library i've found was not maintained in 5 years..

Vincent15:03:42

In the Clojure-realm, this typically means the library is done and safe for use. You can use random-uuid when you say snowflake id maybe cuid would fit the bill or do you mean 0.% probability collision rate? (check table, generate unique or generate again)