-
Notifications
You must be signed in to change notification settings - Fork 56
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
Add some stats to the Trades view #357
Conversation
app/renderer/views/Trades.js
Outdated
stats: await appContainer.swapDB.lastMonthStats(), | ||
}); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Niceeee, btw there is an index on swap.timeStarted
so you should be able to query directly on that.
Something like:
this.db.find({
selector: {timeStarted: {$gt: oneMonthAgo}},
sort: [{timeStarted: 'desc'}],
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also might be nice to abstract it into swapDB.statsSince(timestamp)
so we could easily reuse it for all time stats, weekly stats etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could even add it directly into getSwaps()
.
So getSwaps()
gets all swaps and getSwaps(timestamp)
returns swaps since the timestamp.
Or maybe it would be better to add a PouchDB query object that gets merged with the default query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Fixed. I made a since
and sortoption for convenience, but also
query` option that trump those for maximum power!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
export default Trades; | ||
export default withState(Trades, {}, { | ||
async componentDidMount() { | ||
/// TODO: This is only here temporarily until we move the swap stuff to the App container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to move the swap state to state in the AppContainer instead of being in the Exchange container as it's also needed by the Trades view, and it's awkward import the Exchange container there.
Perfect 👌 |
@sindresorhus I just noticed two issues with this.
|
You're basing this on just a few swaps though. What happens when the user has thousands of swaps? Eventually, we'll also want to move to pagination. So I don't think we should move away from the query interface just because it's a little bit slower on an insignificant amount of data. |
Fair point. |
Per discussion in Slack.