Skip to content
This repository has been archived by the owner on Oct 28, 2023. It is now read-only.

Commit

Permalink
Improved votes sparkline formula
Browse files Browse the repository at this point in the history
  • Loading branch information
andybets committed Feb 7, 2018
1 parent 36fef14 commit 2f36a93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion node-vue-cli/my-project/src/SearchResultsListPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
loadNewlyDisplayedImages: function() {
for (var i=0; i<4; i++) {
window.setTimeout(function() {window.dispatchEvent(new Event('resize'))}, 200);
window.setTimeout(function() {console.log('t'); window.scroll(window.scrollX, window.scrollY+1)}, 200*i);
window.setTimeout(function() {window.scroll(window.scrollX, window.scrollY+1)}, 200*i);
window.setTimeout(function() {window.scroll(window.scrollX, window.scrollY-1)}, 200*i);
}
}
Expand Down
11 changes: 8 additions & 3 deletions web/project/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,23 @@ def get_sparkline_data_from_content(steem_post_content):
df = pd.DataFrame(data)
df['rshares'] = df['rshares'].apply(int)
times = pd.to_datetime(df['time'])
df['interval'] = ((times.astype(pd.np.int64)/10**9)/300).astype(pd.np.int64)
df['interval'] = ((times.astype(pd.np.int64)/10**9)/60).astype(pd.np.int64) # one minute interval
df = df[['interval', 'rshares']]
dd = []
mins = 0
for t in range(df['interval'].min(), df['interval'].max()):
dd.append({'interval': t, 'rshares': 0})
mins += 1
if mins > 10080: # limit to one week of votes
break
df2 = pd.DataFrame(dd)
df = df.append(df2)
df = df.sort_values(['interval'])
bins = pd.np.linspace(df.interval.min(), df.interval.max(), 15)
# group into 20 bins for sparkline values
bins = pd.np.linspace(df.interval.min(), df.interval.max(), 20)
df = df.groupby(pd.np.digitize(df.interval, bins))['rshares'].sum()
df = df.cumsum()
return str(df.tolist())
return str([0] + df.tolist())

def get_voters_list_from_content(steem_post_content):
data = steem_post_content['active_votes']
Expand Down

0 comments on commit 2f36a93

Please sign in to comment.