Published
Edited
Apr 22, 2021
Insert cell
md`# Polymarket Subgraph Last Seen Today`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
query = `query ($first: Int!, $skip: Int!, $startDate: BigInt!, $endDate: BigInt!) {
accounts(first: $first, skip: $skip, where: { lastSeenTimestamp_gt: $startDate, lastSeenTimestamp_lte: $endDate }) {
lastSeenTimestamp
id
transactions(first:1 orderBy: timestamp, orderDirection: asc){
timestamp
}

}
}
`
Insert cell
object
Insert cell
Insert cell
momentStartDate = parseInt(moment(object.startDate).format('x')) / 1000
Insert cell
momentEndDate = parseInt(moment(object.endDate).format('x')) / 1000
Insert cell
accountData = getData(query, {startDate: momentStartDate, endDate: momentEndDate, first: object.first, skip: object.skip})
Insert cell
viewof exportForm = form(html`<form>
<select name="exportFormDataType">${Object.keys(accountData.data).map(each => html`<option value="${each}">${each}</option>`)}</select></form>
`)
Insert cell
exportForm.exportFormDataType.toString()
Insert cell
DOM.download(exportCSVFile(accountData.data[exportForm.exportFormDataType], exportForm.exportFormDataType + ".csv"),
exportForm.exportFormDataType + ".csv",
"Export data"
)
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
queryTraders = `query ($first: Int!, $skip: Int!, $startDate: BigInt!, $endDate: BigInt!) {
accounts(first: $first, skip: $skip, where: { lastSeenTimestamp_gt: $startDate, lastSeenTimestamp_lte: $endDate }) {
lastTradedTimestamp
id
transactions(first:1 orderBy: timestamp, orderDirection: asc){
timestamp
}

}
}
`
Insert cell
traderData = getData(queryTraders, {startDate: momentStartDate, endDate: momentEndDate, first: object.first, skip: object.skip})
Insert cell
viewof exportForm2 = form(html`<form>
<select name="exportFormDataType">${Object.keys(traderData.data).map(each => html`<option value="${each}">${each}</option>`)}</select></form>
`)
Insert cell
DOM.download(exportCSVFile(traderData.data[exportForm.exportFormDataType], exportForm.exportFormDataType + ".csv"),
exportForm.exportFormDataType + ".csv",
"Export data"
)
Insert cell
md`# All Accounts`
Insert cell
accountsData = getData(`
query ($first: Int!, $skip: Int!) {
global(id: "") {
numTraders
}

}
`, {first: 1000, skip: 0})
Insert cell
accountsData2 = getData(
`
query ($first: Int!, $skip: Int!) {
accounts (first: $first, skip: $skip) {
id
}

}
`,
{ first: 1000, skip: 5000 }
)
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more