Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements regarding the Sandbox section #103

Open
frnco opened this issue Dec 7, 2021 · 2 comments
Open

Improvements regarding the Sandbox section #103

frnco opened this issue Dec 7, 2021 · 2 comments

Comments

@frnco
Copy link

frnco commented Dec 7, 2021

Sandboxes are a powerful way to go into more detail than would be appropriate in either the Learn section or the API documentation, but not only that, they can also be a powerful tool for new developers to search for mint code that can provide examples of how to implement many features.

The Sandbox section, however, lacks any mechanism to search for sandboxes, even just by author.

Before learning about Mint I was quite mesmerized by Elm, and after over a decade working as a full-stack developer I almost couldn't believe how sensible it was, leagues ahead of anything else I had known (Which range from Curses to GTK to Windows Forms to all the usual front-end suspects such as Bootstrap, React, Angular, VueJS etc). But then I found Mint, and I immediately realized Mint was leagues ahead of even Elm. So I just jumped at it.

As usual, that's when we start finding the problems, and Mint wouldn't be an exception, but the community is great, and the biggest issues I came across were usually more about documentation than problems with the language itself, which is always a good sign. I tried participating in a couple discussions, raising a couple questions, and finally started contributing to the language, and after all of that I finally believe I'm knowledgeable enough to help with documentation, this I forked the website repo (This repo) and started working on it, and one of the things I wanted to do is to make it easier to use sandboxes as a way to learn about mint.

As it stands, the Try section lists the 20 most recent sandboxes, which usually gives you a list with 10+ meaningless and useless sandboxes called "My sandbox" that are basically the result of someone with little to no experience in Mint creating a new Sandbox to check how the syntax works and whether they think Mint is interesting for them. Not exactly the most interesting front-page but to add insult to injury, there's no search box, no way to list some user's sandboxes, no tags, no nothing basically.

So, for starters, I though it'd be a good idea to include a Search Box at the top of the Sandbox listing page, plus a way to list sandboxes by other users (The code for this is pretty much done already, to list your own sandboxes, it's just a matter of making it possible to do the same to other users). I'm already working on those two.

But in addition to that, I think we could really use a few more features, namedly:

  • Bookmarking/Favoriting/Saving/Starring/etc. - Github has stars, browsers have bookmarks, Youtube has "Watch Later", whatever you wanna call it, it'd be a good idea to be able to save sandboxes so you can come back to them later;
  • Likes/Scores/something - A way for users to give some feedback about how useful some sandbox may be, which makes it possible to search/order sandboxes according to how useful others think they are.
  • Lastly, I'd also suggest some form of tagging, still not 100% sure who should decide on Tags, or whether they should be auto-generated based on what classes/methods from the Mint base API are used or whatever. Basically, some way to search for specific stuff.

For now, I'll be working on improving the documentation in the "Learn" section and making it possible to search Sandboxes and list sandboxes by user, which are very useful, I believe, and I don't think anyone would question that. Luckily I'm mostly a Rails dev, and although i'm more of an ERB than a HAML-guy, that's a pretty small thing to get used to in the grand scheme of things, and it was really easy to understand how the site is structured and decide how I could implement the sandbox search and listings and stuff.

However, for the more complex features like Bookmarks, scores, tags etc., those depend on more significant changes, in some cases changing the database structure itself, and I think that's something that should first be discussed with the maintainers, which is the reason I'm starting this issue.

For this first iteration I'm making the search box search only sandbox titles, and the listing by user will use the user id, here's a preview of the scopes for the Sandbox model:

  scope :recent, lambda {
    initial
      .limit(20)
  }

  scope :search, lambda (query_term) {
    initial
      .where(
        "mint_json->>'title' ILIKE ?",
        "%#{query_term}%")
  }

  scope :by_user, lambda (user_id) {
    initial
      .where(user_id: user_id)
      .sort_by(&:title)
  }

  scope :initial, lambda {
    .includes(:user)
    .order(updated_at: :desc)
  }

If you look at the file in master, it doesn't use scopes, instead all of the querying being done in the controller, which everyone agrees is not ideal. I used the package model as a reference to decide how to scope it, and used to opportunity to make the controller properly use the scopes, i.e.:

  def recent
    sandboxes =
      Sandbox
        .recent

    render json: sandboxes
  end
  def index
    with_user do |user|
      sandboxes =
         Sandbox
          .by_user(user.id)
          .as_json(AS_JSON)

      render json: sandboxes
    end
  end

Now I'd like some feedback about the other stuff, whether I should split my changes into smaller PRs so the refactoring and each feature can be evaluated separately etc.

@gdotdesign
Copy link
Member

Hi, thanks for giving some love to the Sandbox ❤️ There are so many things that could work on, and my time is limited between work, family, Mint and other things, so I appreciate the time you put into Mint 🙏

The current version of the Sandbox is basically an MVP, so there can be a lot of features that can be added. I like all of your ideas.

The code looks fine, although the search scope seems off since the mint_json doesn't have a title so I guess you meant to query the sandbox title itself:

  scope :search, lambda (query_term) {
    initial
      .where(
        "title ILIKE ?",
        "%#{query_term}%")
  }

Now I'd like some feedback about the other stuff, whether I should split my changes into smaller PRs so the refactoring and each feature can be evaluated separately etc.

Yes please split it into feature PRs.

@frnco
Copy link
Author

frnco commented Dec 7, 2021

The code looks fine, although the search scope seems off since the mint_json doesn't have a title so I guess you meant to query the sandbox title itself:

Yes, I've actually just copy-pasted stuff for starters, since I was mostly working on documentation, I'm actually only setting up the Database now to test stuff related to the sandbox, so all that code was actually more like pseudo-code, I still haven't actually written the tests or tried running anything, will start working on that today.

Hi, thanks for giving some love to the Sandbox heart There are so many things that could work on, and my time is limited between work, family, Mint and other things, so I appreciate the time you put into Mint pray

The current version of the Sandbox is basically an MVP, so there can be a lot of features that can be added. I like all of your ideas.

It's a pretty great MVP, if I may add. One of the things I like about the Sandbox is that, unless I'm mistaken about it, the sandbox section actually uses Mint for the front-end,and Rails only serves as an API, unlike the Site which actually uses HAML. It'd be great to have the main website written in Mint, but that's obviously not a priority, and it's not worth the effort that would be required to rewrite everything. Still, that's a point for the Sandbox.

And I do realize how hard it is to balance work-life, which is why I try to focus my efforts on collaborating with projects I believe can grow into something I believe in.

Anyways, I'm considering splitting my work the following way:

  • Work on searching sandboxes and listing sandboxes by any arbitrary author (As opposed to just sandboxes you own);
  • Implementing, in the Sandbox front-end, the search box, plus adding the author name to the editor screen when it's not you, and linking author names in both the sandbox list and the editor to a list of sandboxes by that author;
  • Expanding the search back-end to make it more flexible, which will hopefully make it easier to expand in the future while also implement the features required by the following item;
  • Creating a route, in the sandbox front-end, to an advanced search page, which in addition to the search box will allow you to search for specific modules and/or functions (i.e., Sandboxes that use Time or that use Provider.Intersection or maybe Regexp.replace, to mention a few things you people may be uncertain abot how to best use and thus want to check examples of), and possibly search for other stuff like author or do a text search on the code;

Ideally I'd also like to have a way to differentiate sandboxes that are and aren't compiling so people can filter their search to only see stuff that actually works, plus the ability to change how results are sorted, though that'll have to wait until I'm more comfortable with the code before I'm able to decide what can or can't be done, what's worth the effort etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants