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

Webworker Analytics #736

Merged
merged 15 commits into from
Jan 14, 2020
Merged

Conversation

ruler501
Copy link
Contributor

@ruler501 ruler501 commented Dec 8, 2019

I put together a rough proof of concept of one way to do user customizable analytics for #19. You can test it out at https://cubecobra.ruler501.com/cube/analysis/packwars. It supports tables and bar charts currently.
The UI could use a decent amount of work. I'm relatively poor at designing and writing UI so have been focused mostly on getting the functionality working.

The overarching idea is to have analytics be run on the client side over the set of cards in the cube through WebWorkers which provide isolation from the page environment. These scripts would receive messages with the cards and respond with descriptions of the visualization they want for their analytic. I planned to allow responses to render tables, line graphs, bar graphs, pie charts, word clouds and card image with associated text grids(like the token analytic now).
This also introduces a markdown lke language that supports rendering percentages, mana symbols, card images, and card links with autocard.

Further work intended is to add the other visualization supports mentioned, port over all existing analytic functions, add tests, and make the script requirements and how to write more discoverable.

Custom analytics has been dropped from scope for now due to security concerns.

Changes and Features:

  • Calculate analytics on the client side in isolated Webworker contexts.
  • Allow running Filters on the cards before passing to the analytics.
  • Allow custom draft formats for calculating Asfan the analytics can use.
  • Render tabular data returned from analytics including column headers(missing row headers).
  • Render arbitrary chart types returned by the analytics.
  • Render word cloud data returned by analytics.
  • Render card image with caption data returned by analytics.
  • Add analytic script for calculating Asfan and count by color identity set inclusion.
  • Port analytic script for calculating Asfan and count by color identity set equality (UI change needs review).
  • Port analytic script for calculating the type grid.
  • Port analytic script for calculating the cmc graph.
  • Port analytic script for calculating needed tokens and cards that need them.
  • Add analytic script for drawing a word cloud based on tags used in the cube.
  • Document expected inputs and outputs of analytic scripts.
  • Finalize UI and UX for the analytics page.
  • Add tests for included analytic scripts.

Potential Future Work:

  • Allow adding custom analytic scripts
  • Persist custom analytic scripts.
  • Allow editing, deleting, and duplicating analytic scripts.
  • Allow Analytics scripts to have parameters for customizing behavior without editing code.
  • Allow Analytic scripts to take other cubes as parameters.
  • Allow comparing analytics before and after a suggested change from the Maybeboard.

@ruler501 ruler501 force-pushed the webworker-analytics branch 8 times, most recently from d41c21f to bacf56d Compare January 10, 2020 20:10
@ruler501 ruler501 force-pushed the webworker-analytics branch 8 times, most recently from 5c054b2 to ed3ea71 Compare January 12, 2020 00:46
@ruler501 ruler501 changed the title [WIP] Webworker analytics Webworker analytics Jan 12, 2020
@ruler501 ruler501 changed the title Webworker analytics Webworker Analytics Jan 12, 2020
@ruler501 ruler501 force-pushed the webworker-analytics branch 4 times, most recently from 8ac0bbb to 5224492 Compare January 13, 2020 05:29
return cardName;
} else if (section.startsWith('[[')) {
const cardIndex = parseInt(section.substring(2, section.length - 2), 10);
const card = cube.cards[cardIndex];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires this component to be passed a cube object. Can we revise this such that it either: makes an API call to the server asking for the card object that matches the name, or the autocard to a new route on the server that redirects to the correct image.
Then we can use in a lot of other places too, without having to pass through this object.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to change it for this PR, on second thought. I'll create a separate issue for this

Add filters to analysis

Add markdown formatting for analytics.

Update colorCount analytics.
Handle when there are no draft formats for a cube.
Run Prettier on the analytics changes.

Remove the tests for old system. Need to add new tests.

Remove obsolete files.
Fix type breakdown when some colors have no cards.
@dekkerglen dekkerglen merged commit caa2556 into dekkerglen:master Jan 14, 2020
@ruler501 ruler501 mentioned this pull request Jan 15, 2020
21 tasks
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

Successfully merging this pull request may close these issues.

2 participants