Skip to content

Commit

Permalink
Merge pull request #1 from devonChurch/feature/redux
Browse files Browse the repository at this point in the history
Feature: Redux / Sagas and Combinations section
  • Loading branch information
devonChurch authored Jan 18, 2019
2 parents 9765124 + 4109289 commit 6f52bb3
Show file tree
Hide file tree
Showing 27 changed files with 1,277 additions and 640 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ An application that allows a user to investigate every [New Zealand Lotto](https

- 🎛 A _**"Most Frequent"**_ section is also generated by aggregating all drawn _ball_ frequencies regardless of _draw_ order.

- ⚖ Draw combinations are ranked by _size_ and _frequency_ regardless of ball order.
-_Ball_ combinations are ranked by _size_ and _frequency_ regardless of ball order.

- 📋 _Draws_ are ranked in sequential order. This is a great way to cross reference _**combinations**_ and _ball_ _**frequencies**_.

## Demo 👀

Expand All @@ -22,19 +24,19 @@ As of release `v1.1.0` [Web Workers](https://caniuse.com/#feat=webworkers) are u

The workers progress is streamed back to the main application thread and an real time indicator is shown to the user ⏱

![combination-progress](https://user-images.githubusercontent.com/15273233/51017360-b24caf00-15d8-11e9-859c-f724ada0fda4.gif)
![combination-progress](https://user-images.githubusercontent.com/15273233/51363636-cf83ff00-1b3d-11e9-9093-9508ed31ba49.gif)

### Custom Selection

Users can select specific _ball_ numbers and observe their influence over the entire _draw_ spectrum.

![lotto-selection](https://user-images.githubusercontent.com/15273233/50729628-07845d00-11a2-11e9-9c10-c77a08feedf1.gif)
![lotto-selection](https://user-images.githubusercontent.com/15273233/51363633-ceeb6880-1b3d-11e9-8101-ab44d25be817.gif)

### Time Periods

The _draw_ records can also be time sliced to better understand how certain _ball_ numbers rank at different periods in time.

![lotto-time](https://user-images.githubusercontent.com/15273233/50729629-07845d00-11a2-11e9-9e80-42354b824497.gif)
![lotto-time](https://user-images.githubusercontent.com/15273233/51363635-ceeb6880-1b3d-11e9-95f5-49f7f91b9ca7.gif)

## Installation 🤖

Expand All @@ -56,6 +58,20 @@ The _draw_ records can also be time sliced to better understand how certain _bal
npm start
```

## Deployment 🏁

- Create a _Production_ build

```
nvm run build
```

- Deploy application to `gh-pages`

```
nvm run deploy
```

## License 📜

MIT
111 changes: 109 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
{
"name": "shortbread-biscuit",
"version": "1.1.0",
"version": "1.2.0",
"description": "An application that allows a user to investigate every New Zealand Lotto result in detail.",
"private": true,
"homepage": "https://devonchurch.github.io/shortbread-biscuit/",
"dependencies": {
"@types/jest": "^23.3.11",
"@types/lodash.throttle": "^4.1.4",
"@types/node": "^10.12.18",
"@types/react": "^16.7.18",
"@types/react-dom": "^16.0.11",
"@types/react-redux": "^6.0.12",
"antd": "^3.11.6",
"axios": "^0.18.0",
"csvtojson": "^2.0.8",
"lodash.throttle": "^4.1.1",
"moize": "^5.4.1",
"moment": "^2.23.0",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-scripts": "2.1.2",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.7",
"redux-saga": "^0.16.2",
"typescript": "^3.2.2"
},
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions public/lotto-numbers.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Draw,Draw Date,1,2,3,4,5,6,Bonus Ball,2nd Bonus Ball,Power Ball
1820,Saturday 12 January 2019,24,18,4,40,19,6,27,,6
1819,Wednesday 9 January 2019,4,40,11,23,6,12,10,,6
1818,Saturday 5 January 2019,4,23,34,24,2,20,31,,2
1817,Wednesday 2 January 2019,22,31,15,39,11,35,16,,3
1816,Saturday 29 December 2018,33,15,11,2,35,10,5,,8
1815,Wednesday 26 December 2018,40,29,24,3,32,30,20,,1
1814,Saturday 22 December 2018,25,15,10,31,28,27,38,,3
Expand Down
20 changes: 3 additions & 17 deletions public/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ const createRowComparison = () => {

return (table, comparison, comboIndex) =>
table.reduce((acc, row, rowIndex) => {
// if (!totalItems) {
// totalItems = table.length;
// }
// const previous = progress;
// const current = Math.round(((comboIndex + 1) / totalItems) * 100);
// if (current > previous && current !== 100) {
// progress = current;
// postMessage({
// isComplete: false,
// progress
// });
// }

postMessage({
isComplete: false,
progress: comboIndex + 1
Expand All @@ -55,8 +42,6 @@ const createRowComparison = () => {

const compareTable = (table, compareRows) =>
table.reduce((acc, row, index) => {
// console.log(`comparing row ${index}`);
// const data = [...table.slice(0, index), ...table.slice(index + 1)];
const data = table.slice(index + 1);

return [...acc, ...compareRows(data, row, index)];
Expand Down Expand Up @@ -158,8 +143,7 @@ const enrichWithColor = data =>
}));

onmessage = function(event) {
const { json } = event.data;
const prepped = prepareComboData(json);
const prepped = prepareComboData(event.data);
const compareRows = createRowComparison();
const matches = compareTable(prepped, compareRows);
const frequencies = getFrequency(matches);
Expand All @@ -172,4 +156,6 @@ onmessage = function(event) {
isComplete: true,
combinations: colors
});

close();
};
Loading

0 comments on commit 6f52bb3

Please sign in to comment.