blockly-samples icon indicating copy to clipboard operation
blockly-samples copied to clipboard

"Most used" and "Recently used" built-in categories - Block statistics

Open Goldorion opened this issue 3 years ago • 5 comments

Is your feature request related to a problem? Please describe.

I am a contributor to a Minecraft project named MCreator. In this project, Blockly is used for several options, so we want to improve their experience by making their life a bit easier. A few days ago, a user asked me if we could implement a "Most used blocks" category and "Recently used blocks" category.

Describe the solution you'd like

The easiest way for developers of projects would be to have them integrated into Blockly.

Describe alternatives you've considered

Another way to implement this feature would be to have an option to get how many times is used and when the block has been used for the last time. It would require developers more work, but it may add some other possibilities I am not thinking of.

Additional context Maybe having both solutions could be another idea, so Blockly provides these two categories, but we also have block statistics.

Goldorion avatar Oct 12 '21 14:10 Goldorion

Hello,

This can be implemented as a dynamic category using existing APIs: https://developers.google.com/blockly/guides/configure/web/toolbox#dynamic_categories

For that reason, it's probably not something that we'd add to core blockly. However, it is a cool idea for a plugin, so I'm going to transfer this over to the blockly-samples repository as a feature request. That said, it's probably not something the core team will be able to look at in the near future, but it would be great if you or another contributor would like to create a plugin for it! There's more information about plugins on our developer site, and you can also ask over at the forum if you have any questions about how to accomplish this.

maribethb avatar Oct 15 '21 23:10 maribethb

Thank you for your answer. I am not an expert with Blockly, and I don't know JavaScript, so I did not know we could have such a thing for categories. I (or another contributor of the project) will also try to take a look into plugins for Blockly when I will have the time.

Goldorion avatar Oct 17 '21 03:10 Goldorion

Hi,

@jeremyjacob123 and I are interested in working on this plugin and we have a few questions about the specification of these categories.

  1. For "most used blocks," are we only considering blocks currently in the workspace? Or blocks that have been placed the most even if they have been deleted?
  2. Are there any restrictions on the blocks that should be counted, for example, disabled, collapsed, etc.?
  3. Would it be better to have "most used" and "recently used" as separate categories or to combine them into one with a label in between?
  4. What should be the limit on how many blocks are shown in each category?

Are there any other things we should consider?

RichDoherty avatar Feb 17 '22 04:02 RichDoherty

  1. I think it should only consider placed blocks. (blocks in use)
  2. No, every block should be counted.
  3. 2 categories is surely more user friendly.
  4. I never read on Blockly plugins, so I don't know what's possible or not, but I think the best thing do would to allow to change this limit on a configuration file for example. Maybe we could also choose to see all blocks used with no limit. Concerning other things to consider, I will talk with other contributors and the maintainers of the project, so they give leave their opinion too.

Goldorion avatar Feb 17 '22 18:02 Goldorion

Hi @RichDoherty, thanks for your interest in working on this! For now you should work under the assumption that this would be a third-party plugin, where the code would be in your own repository rather than in blockly-samples and you'd publish it on npm yourself. If you are interested in having it be a first-party plugin where the Blockly team does more of the maintenance, we can definitely discuss that as a team and let you know but we'd probably want to see the plugin first.

You can still use our create plugin script and you can also tag us and ask for code reviews (I'd be happy to review for you if you'd like!) even if they are in a different repository.

So with that in mind, the answers are more up to you and/or @Goldorion and other stakeholders who would like to use this plugin. We do recommend that plugins are configurable where possible, so the answer for some of them would be to make it configurable by the user. For an example of that, check out the scroll-options plugin. We provide reasonable defaults for all the options but allow developers to pass in a configuration object as well controlling the various parameters.

Again let us know if you need any help! The documentation for writing plugins is on the developer site under the Plugins tab on the sidebar, but it may be incomplete and/or disorganized. If you have feedback on the documentation itself, that's a project I'm working on currently so I'd love to hear it!

maribethb avatar Feb 17 '22 19:02 maribethb

To circle back around on this, we've added a Suggested Blocks plugin that adds Most Recent and Most Used toolbox categories. If there are any additional features or changes you'd be interested in we're always open to contributions, but you should be able to incorporate it into your project as-is.

gonfunko avatar Feb 16 '23 22:02 gonfunko

To circle back around on this, we've added a Suggested Blocks plugin that adds Most Recent and Most Used toolbox categories. If there are any additional features or changes you'd be interested in we're always open to contributions, but you should be able to incorporate it into your project as-is.

Thank you for your work and your help!

Goldorion avatar Feb 17 '23 04:02 Goldorion