Skip to content

Commit

Permalink
Merge pull request #78 from two-n/master
Browse files Browse the repository at this point in the history
debugging 6
  • Loading branch information
efrymire authored Aug 31, 2018
2 parents b9c5111 + 69bad43 commit 878a111
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions read_and_reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,46 @@ const parse = (text) => {

const makeViz = (data) => {
console.log('vizing... ')
const xScale = scaleLinear()
.domain([data[0][0], data[data.length-1][0]])
.range([0, 10])
const xTicks = xScale.ticks( data.length/2 ).map(d => d.toString().slice(2,4))

const makeVizRow = (values, init='') => {
if(values.length === 0){
return init
} else {
return makeVizRow(values.slice(1), init+'\u3000'.repeat(Math.max(0, xScale(values[0][0]) - init.length))+'\uff0a')

if (data.length) {
const xScale = scaleLinear()
.domain([data[0][0], data[data.length-1][0]])
.range([0, 10])
const xTicks = xScale.ticks( data.length/2 ).map(d => d.toString().slice(2,4))

const makeVizRow = (values, init='') => {
if(values.length === 0){
return init
} else {
return makeVizRow(values.slice(1), init+'\u3000'.repeat(Math.max(0, xScale(values[0][0]) - init.length))+'\uff0a')
}
}
}

const yScale = scaleLinear().domain([max(data, d => d[1]), 0])
const yTicks = yScale.ticks( data.length/2 )
const yStep = yTicks[0] - yTicks[1]
const yScale = scaleLinear().domain([max(data, d => d[1]), 0])
const yTicks = yScale.ticks( data.length/2 )
const yStep = yTicks[0] - yTicks[1]

const xStep = Math.round(xScale.range()[1] / xTicks.length) - 2
let viz = yTicks.map(e => {
let filtered = data.filter(d => d[1] >= +e && d[1] < +e + yStep)
return `${format('.2s')(e)}| ${makeVizRow(filtered)}`
}).join('\n')
viz += '\n' + '\u3000'.repeat(2) + xScale.domain()[0].toString().slice(2,4) + '\uffe3'.repeat(xScale.range()[1]) + xScale.domain()[1].toString().slice(2,4)
const xStep = Math.round(xScale.range()[1] / xTicks.length) - 2
let viz = yTicks.map(e => {
let filtered = data.filter(d => d[1] >= +e && d[1] < +e + yStep)
return `${format('.2s')(e)}| ${makeVizRow(filtered)}`
}).join('\n')
viz += '\n' + '\u3000'.repeat(2) + xScale.domain()[0].toString().slice(2,4) + '\uffe3'.repeat(xScale.range()[1]) + xScale.domain()[1].toString().slice(2,4)

return viz
return viz
} else {
return null
}
}

module.exports.read_and_reply = read_and_reply = (tweetEvent) => {


let quoteStatus = tweetEvent.tweet_create_events[0].is_quote_status
let id = tweetEvent.tweet_create_events[0].id_str
console.log(tweetEvent.tweet_create_events[0])
console.log(quoteStatus)

if (quoteStatus) {
if (quoteStatus && viz.length) {
let user1 = tweetEvent.tweet_create_events[0].user.screen_name
let user2 = tweetEvent.tweet_create_events[0].quoted_status.user.screen_name
let tweet = '@' + user1 + ' ' + '@' + user2 + ' ' + makeViz(parse(tweetEvent.tweet_create_events[0].quoted_status.text))
Expand All @@ -84,7 +88,7 @@ module.exports.read_and_reply = read_and_reply = (tweetEvent) => {
console.log(body)
})

} else {
} else if (viz.length) {
let user = tweetEvent.tweet_create_events[0].user.screen_name
let tweet = '@' + user + ' ' + makeViz(parse(tweetEvent.tweet_create_events[0].text))

Expand All @@ -101,5 +105,7 @@ module.exports.read_and_reply = read_and_reply = (tweetEvent) => {
console.log(body)
})

} else {
null
}
}

0 comments on commit 878a111

Please sign in to comment.