precept

Preception!
alex-dixon 2017-07-05T14:15:26.940087Z

@gdeer81 I have a few guesses as to why that might be. define is not very development friendly at the moment. So using rules instead will help. We decided to use define to showcase the logic, but the app was developed primarily using rules. The reason rule is more dev friendly than define basically comes down to how define‘s name is based upon its consequence, so redefining the consequence produces a new rule and maintains the old one. I’ve been working to fix this along with hot reloading in general. I have it working in Clojure but Clojurescript is a little tricker so it’s taking a bit longer

alex-dixon 2017-07-05T14:19:03.064372Z

This same thing will occur if you rename a rule or delete it from the file. The fix I am working on will rectify this as well. The cause is similar, but you can get around it (somewhat laboriously) by using ns-unmap on the rule you renamed/removed, or by restarting figwheel. Changes to conditions or consequences of rules should work fine, however. In development I found myself adding comments to rules when I wanted to rename them and then renaming them later so I didn’t have to deal with this

alex-dixon 2017-07-05T14:20:41.121563Z

If you have time to let me know more about the problem you ran into I may be able to provide a more helpful answer

gdeer81 2017-07-05T15:07:46.824552Z

@alex-dixon my filtering might be too aggressive https://gist.github.com/gdeer81/b9d69b8c6915cd7f9199a9fa3359e145

gdeer81 2017-07-05T15:11:46.969274Z

oddly enough it was working at one time and then I was trying to do some id truncating for the product description and got an error since you can't treat a uuid like a seq and take 5. but that caused the breakage and even after I backed out the change it still wouldn't show any products. I might need to put some better logging in there

alex-dixon 2017-07-05T15:13:30.030628Z

Yeah heh was just going to mention that as well as a downfall of defines, as they don’t support logging. Forgot to mention that as another reason I typically don’t use them in development right now until I have something nailed down, as my primary method of debugging with where our tooling is at is println

alex-dixon 2017-07-05T15:16:06.122358Z

I think I’d probably converting to rules and add printlns. There might be a problem related to mutual exclusivity and insert-logical. As of the latest version I think we’re surfacing an error in this case

alex-dixon 2017-07-05T15:16:51.148827Z

I might also write a rule that just prints visible product ids

alex-dixon 2017-07-05T15:17:20.165660Z

Not saying you should just letting you know what I might do faced with the same problem

alex-dixon 2017-07-05T15:19:40.248428Z

I’m wondering whether it might be a problem with mutual exclusivity given the introduction of the new category filter. Just noticing the second rule doesn’t have anything to say about the category filter

alex-dixon 2017-07-05T15:19:59.259631Z

@gdeer81 I’m assuming you’re testing with no facts about the filters in the session?

alex-dixon 2017-07-05T15:20:15.268760Z

(in which case all products should be visible instead of none of them)

gdeer81 2017-07-05T15:23:28.384688Z

I extended the filter-option-data map to have a category key that follows the same pattern as the range key `:category [{:label "Food & Drinks", :facts {:db/id :product-filter, :filter-menu/selected "Food & Drinks", :product-filter/category "Food & Drinks"}}...`

alex-dixon 2017-07-05T15:25:41.463394Z

Cool. That seems right assuming the string is an exact match for the category attribute of a product

alex-dixon 2017-07-05T15:27:10.516804Z

Another debugging thing if you have a CLJS repl you can see the state that the views see with @precept.state/store. It’s also an object representation of the state in the session once the rules are done firing

gdeer81 2017-07-05T15:28:29.565109Z

ah yes, that's another thing I was looking for. Cool so at least I know my products are loaded and I can scratch that concern off my list

gdeer81 2017-07-05T15:38:43.930250Z

I can even see at the cljs repl (get-in @precept.state/store [:app :visible-product/id]) has products in it

alex-dixon 2017-07-05T15:38:58.938580Z

oh!

alex-dixon 2017-07-05T15:39:31.957460Z

Hm. Ok. Are they showing up under the products subscription as well?

gdeer81 2017-07-05T15:41:18.021094Z

how do I see that?

alex-dixon 2017-07-05T15:42:04.048060Z

Should be in @precept.state/store near :precept.spec.sub/request :products

alex-dixon 2017-07-05T15:42:42.070214Z

The id of the request should have a :precept.spec.sub/response with a map for the value

gdeer81 2017-07-05T15:44:46.141540Z

so if I do (keys @precept.state/store) I should see a :precept.spec.sub/request key?

alex-dixon 2017-07-05T15:45:14.157686Z

I think it’s keyed by UUID actually

alex-dixon 2017-07-05T15:45:46.176963Z

Are you able to do a textual search within the REPL? That’s normally how I try to find things but I use IntelliJ which allows that

alex-dixon 2017-07-05T15:46:56.217210Z

Another thing I might do in this situation is add a let block above the consequence of the sub and print what I’m looking for:

(defsub :products
....
=>
(let [_ (println "HEY" ?thing)
  {:my-sub-as-it-exists ?foo...}

gdeer81 2017-07-05T15:47:34.240215Z

I got kind of excited to try this out right away so I just jumped in at the command line and didn't set it up as a proper project in intellij so I'm just editing with sublime

alex-dixon 2017-07-05T15:48:01.255307Z

Oh nice. Didn’t know you could do that even

gdeer81 2017-07-05T15:48:45.281108Z

yeah, one command prompt for lein run and one for figwheel and just editing raw files with no context menus or helpers in sublime or notepad++

alex-dixon 2017-07-05T15:48:51.284729Z

If the store prints reasonably in the browser console that might be another place that would allow find search

gdeer81 2017-07-05T15:49:38.312972Z

yeah I can console log at the repl and see what the browser says

alex-dixon 2017-07-05T15:51:21.373421Z

Sorry for the difficulty. Dev tools have been near the top of my priorities but there’ I haven’t been able to find time to do it. For what it’s worth I think the information that we need for a better debug story is pretty much all there, we just need a better way to navigate and visualize it. This should be even more the case once we can redefine/alter rules and maintain the same state

gdeer81 2017-07-05T16:04:09.824161Z

yeah I wasn't expecting developer friendliness out the gate. I'm tempted to just scrap this code and start clean but I feel like I'll get more out of it if I keep banging my head against this wall until the wall cracks or my head does

gdeer81 2017-07-05T16:58:33.542078Z

it looks like the problem was my subscriptions were broken somehow. maybe there was a silent error somewhere that was keeping them from initializing.

alex-dixon 2017-07-05T17:09:31.875983Z

Hm. Ok

alex-dixon 2017-07-05T17:10:24.903293Z

You think they may not have initialized via the view, or that one wasn’t reporting results in the rules?

gdeer81 2017-07-05T17:16:12.075202Z

not sure, I'm going to try to reproduce now that I have it working again

gdeer81 2017-07-05T17:35:19.657309Z

well the cool thing is none of my category stuff broke it.

gdeer81 2017-07-05T17:36:04.679697Z

it was just from trying to include a truncated id in the description by doing (str (take 5 id) " description text")

gdeer81 2017-07-05T17:36:20.687688Z

in the product defn in views.cljs

gdeer81 2017-07-05T17:37:36.725635Z

basically the whole ui goes dead since I guess it breaks subscriptions.

gdeer81 2017-07-05T17:39:18.776643Z

then if you reload the page all the products disappear because the cache is cleared and it's not listening for products anymore

gdeer81 2017-07-05T17:40:10.801996Z

fixing the error and saving the file doesn't work. doing (reset-autobuild) in the cljs repl doesn't fix it either

gdeer81 2017-07-05T18:45:38.829350Z

lein clean doesn't seem to fix the issue either. This is a big issue since a small error can totally tank your whole dev flow.

gdeer81 2017-07-05T18:49:53.962874Z

Then again this just may be a cljs or figwheel workflow issue. I don't do a lot of development with clojurescript so I'm just swinging in the dark when trying to debug or fix an issue

gdeer81 2017-07-05T20:43:08.235141Z

@alex-dixon any considerations I should keep in mind while adding subscriptions in development? defsub doesn't seem to be repl driven development friendly either

gdeer81 2017-07-05T21:02:16.773508Z

😆 added a new dropdown for category filter. the value you click on shows up as the value for the price filter...EDIT: update this was fixed by using the correct keyword, :filter-menu2/selected, in the facts for the category menu options instead of :filter-menu/selected

gdeer81 2017-07-05T21:03:49.814840Z

maybe frontend development just isn't for me.

gdeer81 2017-07-05T21:40:10.695260Z

I think I've finally hit a problem that is precept related. I'm trying to implement multiple refinements like "toys under $10" and my current rules are like "okay, here are the toys, one for 80 and one for 8" so then I click on "$0 to $10" and it then goes "okay, here are those two toys again and every other product that's under $10"

gdeer81 2017-07-05T21:41:45.731498Z

then I click on "Health" category and it says "okay here are all the health products plus all the products under $10"

gdeer81 2017-07-05T21:43:21.766719Z

this also screws up the sorting lol