Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 12 commits
  • 11 files changed
  • 0 commit comments
  • 2 contributors
32 README.md
View
@@ -2,25 +2,31 @@ bamboo-meteor-client
====================
A basic bamboo client built on meteor.js
-v0.1: emulate /static/bar_graphs.html on bamboo (see example at http://optimus.modilabs.org:9000/static/bar_graphs.html)
+v0.1: emulate /static/bar_graphs.html on bamboo
installation
============
Install meteor and packages:
- curl install.meteor.com | /bin/sh
- meteor add coffeescript
- meteor add jquery
+run with meteor:
-Install node (download from http://nodejs.org) and request package:
-
- npm install request
+ if you are running Mac, Ubuntu, Debian Centos of Fedora:
+ > curl install.meteor.com | /bin/sh
+ else:
+ > git clone http://github.com/meteor/meteor.git
+ > cd meteor
+ > ./install
+ then:
+ > git clone https://github.com/modilabs/bamboo-meteor-client.git
+ > cd /bamboo-meteor-client/bamboo-meteor/
+ > meteor
+ go to localhost:3000 you'll see
-Run meteor, in your bamboo-meteor-client directory:
+ you can also run with node after you compiled the bundle with meteor:
- meteor
+Install node (download from http://nodejs.org)
-Browse to localhost:3000
+please see details at http://docs.meteor.com/#deploying
deployment
==========
@@ -28,10 +34,4 @@ Currently it is deployed at
http://bamboo.meteor.com
Please check this testing site for the newest deployment before we migrate it to bamboo site
->
- _ _ _
-| |__ ___| | | ___
-| '_ \ / _ \ | |/ _ \
-| | | | __/ | | (_) |
-|_| |_|\___|_|_|\___/
BIN  bamboo-client/client/.bamboo.html.swp
View
Binary file not shown
BIN  bamboo-client/client/.client.coffee.swp
View
Binary file not shown
10 bamboo-client/client/bamboo.css
View
@@ -50,3 +50,13 @@ input{
}
/*myf's color 74E01B*/
/*nanzhu's color CCE89B*/
+
+.box {
+ border:1px solid;
+}
+.control .row {
+ margin-left:20px;
+}
+.mainbody {
+ margin:50px;
+}
188 bamboo-client/client/bamboo.html
View
@@ -7,14 +7,23 @@
<div class="container-fluid">
{{> url_entry}}
</div>
- {{> processing}}
- {{> body_render}}
- <div id="d3select"></div>
+ <div class="mainbody">
+ {{> processing}}
+ {{> body_render}}
+ <div id="d3select"></div>
+ </div>
</body>
+
<template name="body_render">
{{#if show}}
{{> introduction}}
- <div class="hero-unit span8 offset1">
+ {{> graphing_block}}
+ {{> add_new_graph}}
+{{/if}}
+</template>
+
+<template name="graphing_block">
+ <div class="well span8 offset1">
<div class="control">
{{> control_panel}}
</div>
@@ -22,9 +31,7 @@
{{> graph}}
</div>
</div>
-{{/if}}
</template>
-
<template name="url_entry">
{{#if current_dataset_url}}
@@ -55,15 +62,132 @@
{{/if}}
</template>
+<template name="processing">
+{{#if ready}}
+ <div class="well span8 offset1">
+ <h1>Preparing your dataset, just a split second..</h1>
+ <img src="drop.gif">
+ </div>
+{{/if}}
+</template>
+
+<template name="introduction">
+{{#if ready}}
+<div class="well span8 offset1">
+
+
+ <p>You are accessing the dataset from {{url}}</p>
+ <p>There are {{num_cols}} fields you can choose to chart</p>
+ <table border="1"><tr><td>
+ <p> </p>
+ {{#if show_all}}
+ {{#each one}}
+ <p><a href="https://topol.cartodb.com/tables/gujarat/embed_map" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ {{#if long}}
+ <div class="btn pull-right" id="hideBtn">
+ hide
+ </div>
+ {{/if}}
+ {{else}}
+ {{#each schema_lessone}}
+ <p><a href="https://topol.cartodb.com/tables/gujarat/embed_map" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ <div class="btn pull-right" id="moreBtn">
+ more
+ </div>
+ {{/if}}
+ </td><td>
+ {{#if show_all}}
+ {{#each two}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ {{#if long}}
+ <div class="btn pull-right" id="hideBtn">
+ hide
+ </div>
+ {{/if}}
+ {{else}}
+ {{#each schema_lesstwo}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ <div class="btn pull-right" id="moreBtn">
+ more
+ </div>
+ {{/if}}
+ </td><td>
+ {{#if show_all}}
+ {{#each three}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ {{#if long}}
+ <div class="btn pull-right" id="hideBtn">
+ hide
+ </div>
+ {{/if}}
+ {{else}}
+ {{#each schema_lessthree}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ <div class="btn pull-right" id="moreBtn">
+ more
+ </div>
+ {{/if}}
+ </td><td>
+ {{#if show_all}}
+ {{#each four}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ {{#if long}}
+ <div class="btn pull-right" id="hideBtn">
+ hide
+ </div>
+ {{/if}}
+ {{else}}
+ {{#each schema_lessfour}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ <div class="btn pull-right" id="moreBtn">
+ more
+ </div>
+ {{/if}}
+
+ </td><td>
+ {{#if show_all}}
+ {{#each five}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ {{#if long}}
+ <div class="btn pull-right" id="hideBtn">
+ hide
+ </div>
+ {{/if}}
+ {{else}}
+ {{#each schema_lessfive}}
+ <p><a href="http://www.w3schools.com/" target="_blank">{{label}} ({{simpletype}})</a></p>
+ {{/each}}
+ <div class="btn pull-right" id="moreBtn">
+ more
+ </div>
+ {{/if}}
+
+
+ </td></tr></table>
+
+
+ </div>
+{{/if}}
+</template>
+
<template name="control_panel">
{{#if show}}
<div class="page-header">
- <h3>Control Panel</h3>
+ <h3>Graphing Control Panel</h3>
</div>
- <div class="row offset1">
+ <div class="row">
<b>View</b>
{{chosen}}
- <select class="chosen" id="view">
+ <select class="chosen" id="view" >
{{#each fields}}
<option>{{this}}</option>
{{/each}}
@@ -78,47 +202,39 @@
Generate
{{num_graph}}
graphs
- </div>
- <div class="btn pull-right" id="chartBtn">
- Chart
+ <div class="btn pull-right" id="chartBtn">
+ Chart
+ </div>
</div>
{{/if}}
</template>
-<template name="graph">
-{{#if show}}
- {{>waiting_graph}}
- {{charting}}
- <div class="d3_graph" id="{{field}}_graph"></div>
-{{/if}}
-</template>
-
<template name="waiting_graph">
{{#if exist}}
- Graphs:
+ <h3>Showing Graph of {{field}} {{group_by}}</h3>
{{else}}
Proccessing the graphs, waiting a split second...
<img src="drop.gif">
{{/if}}
</template>
-
-<template name="introduction">
-{{#if ready}}
-<div class="hero-unit span11">
- <p>You are accessing the dataset from {{url}}</p>
- <p>There are {{num_cols}} fields you can choose to chart</p>
- {{#each schema}}
- <p>{{label}} ({{simpletype}})</p>
- {{/each}}
-</div>
+
+<template name="graph">
+{{#if show}}
+ {{>waiting_graph}}
+ {{charting}}
+ <div class="d3_graph" id="{{field}}_graph"></div>
{{/if}}
</template>
-<template name="processing">
-{{#if ready}}
- <div class="hero-unit span8 offset1">
- <h1>Preparing your dataset, just a split second..</h1>
- <img src="drop.gif">
+
+
+
+<template name="add_new_graph">
+{{#if show}}
+ <div class="well span8 offset1">
+ <div class="btn pull-right" id="addGraphBtn">
+ Add A Graph
+ </div>
</div>
{{/if}}
</template>
317 bamboo-client/client/client.coffee
View
@@ -13,6 +13,11 @@ constants =
if root.Meteor.is_client
#every function can be accessed by the template it is defined under
+ ##################BODY RENDER#####################
+ root.Template.body_render.show =->
+ Session.get('currentDatasetURL') and Session.get('fields')
+
+ ###################URL-Entry###########################
root.Template.url_entry.events = "click .btn": ->
url = $('#dataSourceURL').val()
Session.set('currentDatasetURL', url)
@@ -37,10 +42,190 @@ if root.Meteor.is_client
root.Template.url_entry.current_dataset_url = ->
Session.get('currentDatasetURL')
- root.Template.control_panel.show = ->
- #if there is currentDatasetURL in session-> show
+ ####################PROCESSING######################
+ root.Template.processing.ready =->
+ Session.get('currentDatasetURL') and not Session.get('fields')
+
+ #################INTRODUCTION###########################
+ root.Template.introduction.ready =->
Session.get('currentDatasetURL') and Session.get('fields')
+ root.Template.introduction.num_cols =->
+ Session.get('fields').length
+
+ root.Template.introduction.schema =->
+ schema = Session.get('schema')
+ _.values schema
+
+ root.Template.introduction.one =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^1_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result
+
+ root.Template.introduction.two =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^2_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result
+
+ root.Template.introduction.three =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^3_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ console.log "heres three"
+ console.log result
+ result
+
+ root.Template.introduction.four =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^4_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result
+
+ root.Template.introduction.five =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^5_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result
+
+ Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
+ root.Template.introduction.schema_lessone =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^1_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result.slice(0,5)
+
+ root.Template.introduction.schema_lesstwo =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^2_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result.slice(0,5)
+
+ root.Template.introduction.schema_lessthree =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^3_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result.slice(0,5)
+
+
+ root.Template.introduction.schema_lessfour =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^4_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result.slice(0,5)
+
+ root.Template.introduction.schema_lessfive =->
+ schema = Session.get('schema')
+ all_val = _.values schema
+ result = []
+ pattern = /^5_.*/
+ for item in all_val
+ label = item.label
+ if label.match(pattern)
+ obj =
+ label : item['label'].slice(2)
+ simpletype : item['simpletype']
+ result.push(obj)
+ result.slice(0,5)
+
+ root.Template.introduction.schema_less =->
+ schema = Session.get('schema')
+ arr = _.values schema
+ arr.slice(0,5)
+
+
+
+
+ root.Template.introduction.events= {
+ "click #moreBtn": ->
+ Session.set('show_all', true)
+ "click #hideBtn": ->
+ Session.set('show_all', false)
+ }
+
+ root.Template.introduction.long =->
+ Session.get('fields').length > 5
+
+ root.Template.introduction.show_all =->
+ Session.get('fields').length < 6 or Session.get('show_all')
+
+ #####################Control-Panel##################
+ root.Template.control_panel.show = ->
+ #if there is currentDatasetURL in session-> show
+ Session.get('currentDatasetURL') and Session.get('fields') and not Session.get('graph')
# have to write this code to make chosen recognized in jquery
root.Template.control_panel.chosen= ->
Meteor.defer(->
@@ -73,6 +258,21 @@ if root.Meteor.is_client
Session.set('currentView', view_field)
Session.set('graph', false)
+ ##################WAITING_GRAPH######################
+ root.Template.waiting_graph.exist =->
+ exist = Session.get('graph')
+
+ root.Template.waiting_graph.field =->
+ Session.get("currentView")
+ root.Template.waiting_graph.group_by =->
+ g = Session.get("currentGroup")
+ if g is ""
+ return ""
+ else
+ return "grouped by " + g
+
+
+ #####################GRAPH#######################333
root.Template.graph.show=->
url = Session.get('currentDatasetURL')
group = Session.get('currentGroup')
@@ -95,27 +295,13 @@ if root.Meteor.is_client
,1000)
""
- root.Template.processing.ready =->
- Session.get('currentDatasetURL') and not Session.get('fields')
-
- root.Template.introduction.ready =->
- Session.get('currentDatasetURL') and Session.get('fields')
-
- root.Template.introduction.num_cols =->
- Session.get('fields').length
-
- root.Template.introduction.schema =->
- url = Session.get('currentDatasetURL')
- obj = Schemas.findOne
- datasetURL:url
- _.values obj.schema
-
- root.Template.body_render.show =->
- Session.get('currentDatasetURL') and Session.get('fields')
-
- root.Template.waiting_graph.exist =->
- exist = Session.get('graph')
+ ##########ADDNEW GRAPH#####################################
+ root.Template.add_new_graph.show =->
+ Session.get('graph')
+ root.Template.add_new_graph.events = "click #addGraphBtn":->
+ Session.set('add_new_graph_flag', true)
+
############# UI LIB #############################
@@ -147,43 +333,13 @@ Meteor.methods(
- make_poly_chart: (obj) ->
- [div, dataElement] = obj
- #dataElement.titleName = makeTitle(dataElement.name)
- dataElement.titleName = dataElement["groupVal"]
- data = dataElement.data
- dataSize = _.size(data)
-
- unless (dataSize is 0) or (dataElement.name.charAt(0) is '_')
- keyValSeparated =
- x: _.keys(data)
- y: _.values(data)
- if typeof keyValSeparated.y[0] is "number"
- #if number make pure histogram
- #histogram logic
- gg.graph(keyValSeparated).layer(gg.layer.bar().map('x','x').map('y','y')).opts(
- width: Math.min(dataSize*60 + 100, 220)
- height: "270"
- "padding-right": "50"
- title: dataElement.titleName
- "title-size":12
- "legend-position":"bottom"
- ).render(div)
make_single_chart: (obj) ->
- [div, dataElement] =obj
+ [div, dataElement, min, max] =obj
#chart based on groupable property
if dataElement.name in Session.get("groupable_fields")
- barchart(dataElement,div)
+ barchart(dataElement,div,min,max)
else
- boxplot(dataElement,div)
-
- d3testing: (data)->
- char_element = data ? mock_element
- d3chart(char_element, "#d3select")
-
- boxtesting: (data) ->
- char_element = data ? mock_element_2
- boxplot(char_element, "#d3select")
+ boxplot(dataElement,div,min,max)
clear_graphs: ->
@@ -191,70 +347,51 @@ Meteor.methods(
for item in graph_divs
$(item).empty()
-# charting: ->
-# Meteor.call('clear_graphs')
-# url = Session.get("currentDatasetURL")
-# group = Session.get("currentGroup") ? "" #some fallback
-# item_list = Summaries.find(datasetURL:url, groupKey:group).fetch()
-# list = Meteor.call('grouping', item_list)
-# $.each(list, (key,value)->
-# for item in value
-# div = "#"+item["name"]+".gg"
-# Meteor.call("make_single_chart",[div,item])
-# )
field_charting: ->
Meteor.call('clear_graphs')
url = Session.get("currentDatasetURL")
group = Session.get("currentGroup") ? "" #some fallback
field = Session.get("currentView")
+ groupable = Session.get("groupable_fields")
item_list = Summaries.find
datasetURL: url
groupKey: group
name: field
.fetch()
- div = "#" + field+"_graph"
+ div = $("#" + field+"_graph").get(0)
+ max_arr = item_list.map (item)->
+ if item.name in groupable
+ maxing(item.data)
+ else
+ item.data.max
+ max = _.max(max_arr)
+ min_arr = item_list.map (item)->
+ if item.name in groupable
+ mining(item.data)
+ else
+ item.data.min
+ min = _.min(min_arr)
for item in item_list
- Meteor.call("make_single_chart", [div, item])
-
- grouping: (list) ->
- fin = {}
- #group_list = _list.pluck("groupVal")
- #group_list = (list.map (x)->x.groupVal).unique()
- group_list = list.map (x)->x.groupVal
- for item in group_list
- fin[item]=[]
- for item in list
- group = item['groupVal']
- fin[group].push(item)
- fin
+ Meteor.call("make_single_chart", [div, item, min, max])
+
get_fields:(url)->
fin = []
schema_dataset = Schemas.findOne
datasetURL: url
- #alert "in get_fields:schema_dataset " + schema_dataset
if schema_dataset
console.log "data found: "
names = []
schema = schema_dataset['schema']
for name of schema
names.push(name)
- #fields is an array []
fin = names
- #alert "found schema" + fin
- ###
- else
- dataset = Datasets.findOne(url: url)
- if (!dataset)
- Meteor.call('register_dataset', url)
- ###
try
Session.set('schema', schema_dataset.schema)
Session.set('fields', fin)
catch error
console.log "no schema yet.. waiting"
- #alert fin
#testing only
alert: (something)->
53 bamboo-client/client/d3chart.coffee
View
@@ -43,14 +43,34 @@ maxing = (data) ->
values.remove(elem)
_.max(values)
+mining = (data) ->
+ values = _.values(data)
+ for elem in values
+ if typeof elem is 'string'
+ values.remove(elem)
+ _.min(values)
+
+
#div is <div>location on the html page
-barchart= (dataElement,div)->
+d3chart = (dataElement,div)->
+ data = dataElement.data
+ display = ['min','25%','50%','75%','max']
+ keys = _.keys(data)
+ box_flag = true
+ for item in display
+ if item not in keys
+ box_flag = false
+ if box_flag is true
+ boxplot(dataElement,div)
+ else
+ barchart(dataElement,div)
+
+barchart= (dataElement, div, min, max)->
name = dataElement.name
data = data_massage(dataElement.data)
y_padding = 15
x_padding = 20
font = 10
- max = maxing(dataElement.data)
name_max = _.max(_.map(_.keys(dataElement.data), (word)->
word.length
@@ -72,7 +92,7 @@ barchart= (dataElement,div)->
y_scale = d3.scale.linear()
.domain([0,max])
- .range([height - y_padding, 0])
+ .range([height - y_padding, y_padding])
x_scale = d3.scale.linear()
@@ -90,7 +110,13 @@ barchart= (dataElement,div)->
y_scale d.value
)
.attr('width',(d)->
- (width-x_padding) / data.length - bar_padding
+ w = (width-x_padding) / data.length - bar_padding
+ ###
+ if w > 45
+ return 45
+ else
+ w
+ ###
)
.attr('height',(d)->
height - y_padding - y_scale d.value
@@ -153,14 +179,19 @@ barchart= (dataElement,div)->
.attr("font-size", "10px")
.call(y_axis)
-boxplot= (dataElement, div)->
+boxplot= (dataElement, div, min, max)->
console.log "enter"
name = dataElement.name
data = dataElement.data
+ if data.count is 1
+ display_name = dataElement.groupVal
+ display_value = dataElement.data.min
+ dataElement.data = {}
+ dataElement.data[display_name]=display_value
+ return barchart(dataElement, div, min, max)
y_padding = 15
x_padding = 20
font = 10
- max = maxing(dataElement.data)
display = ['min','25%','50%','75%','max']
width = 200
@@ -172,7 +203,7 @@ boxplot= (dataElement, div)->
.attr('height',height)
y_scale = d3.scale.linear()
- .domain([data.min, data.max])
+ .domain([min, max])
.range([height-y_padding, y_padding])
y_axis = d3.svg.axis()
@@ -180,6 +211,14 @@ boxplot= (dataElement, div)->
.orient("left")
.ticks(5)
+ svg.append("text")
+ .text(dataElement.groupVal)
+ .attr('x', width/3)
+ .attr('y', height)
+ .attr("font-family", "Monospace")
+ .attr("font-size", 15 + "px")
+ .attr("fill", "black")
+
svg.selectAll("text")
.data(data_massage(data))
.enter().append("text")
14 bamboo-client/public/test.csv
View
@@ -0,0 +1,14 @@
+1_DistrictID,1_State,1_DistrictName,1_DistrictGCAKharif,1_DistrictGCARabi,1_DistrictGCASummer,1_DistrictGIAKharif,1_DistrictGIARabi,1_DistrictGIASummer,1_GWDepth,1_EnergyKharif,1_EnergyRabi,1_EnergySummer,1_EnergyTotal,2_Lighting_Households,2_Lighting_Electricity,2_Lighting_Kerosene,2_Lighting_Solar,2_Lighting_Oil,2_Lighting_Other,2_Lighting_NoLight,2_Lighting_Status,3_Cooking_Household,3_Cooking_FireWood,3_Cooking_CropResidue,3_Cooking_CowdungCake,3_Cooking_Coal,3_Cooking_Kerosene,3_Cooking_LPG,3_Cooking_Electricity,3_Cooking_Biogas,3_Cooking_Other,3_Cooking_NoCooking,3_Cooking_category,4_NIA_Canals_Govt,4_NIA_Canals_Pvt,4_NIA_Canals_Total,4_NIA_Tank,4_NIA_Wells_Tube,4_NIA_Wells_Other,4_NIA_OtherSource,4_NIA_Total,4_GIA_Canals_Govt,4_GIA_Canals_Pvt,4_GIA_Canals_Total,4_GIA_Tank,4_GIA_Wells_Tube,4_GIA_Wells_Other,4_GIA_OtherSource,4_GIA_Total,4_ReportingArea,4_Forests,4_NonCultivable_non_Argicultural,4_NonCultivable_Barren,4_NonCultivable_Total,4_Uncultivated_Pastures,4_Uncultivated_MiscPlantaion,4_Uncultivated_CulturableWasterLand,4_Uncultivated_Total,4_FallowLand_NotCurrent,4_FallowLand_Current,4_FallowLand_total,4_NetAreaSown,4_TotalCroppedArea,4_AreaMultipleSowing,5_TotalYield,5_GCA,5_GIA,5_GRA,5_ExtraYeild_kilotonnes
+15715,Andhra Pradesh, Adilabad ,403809.1,299982.9,187358,187358,16.13492481,108227.4537,26.54947917,48.39068677,201.930961,23.14694373,273.4685915,177,821,169,737,6,183,766,288,109,738,Urban,177821,50263,2,58,357,2,135,3,909,116,828,143,914,717,497,Urban,5405,0,5405,4574,29318,23478,880,63655,5405,0,5405,4574,44509,25421,880,80789,1610500,689517,60684,43920,104604,14234,8504,14737,37475,66318,115611,181929,596975
+15836,Gujarat, Ahmadabad ,69189,55839,43264,0,0,0,0,-100,-100,-100,-300,12,65,770,12,45,177,14,218,393,908,782,4,292,Urban,1265770,120965,3,574,6,254,2,694,1,73,623,9,40,860,220,13,42,322,4,216,Urban,61000,0,61000,4500,73000,69400,1600,209500,71400,0,71400,4500,106400,93100,1600,277000,774800,10600,73400,65900,139300
+15837,Gujarat, Amreli ,69189,55839,43264,0,0,0,0,-100,-100,-100,-300,75,180,72,532,1,912,28,97,96,515,Urban,75180,19896,2,342,1,811,311,5,565,44,541,12,367,59,276,Urban,7700,0,7700,500,2300,165600,1800,177900,7700,0,7700,500,2300,199000,1800,211300,739200,36000,46200,24100,70300,54300,0,11900,66200,1300,15000,16300,550400
+15838,Gujarat, Anand ,520242,109700,78057,0,0,0,0,-100,-100,-100,-300,1,30,95,1,21,849,6,696,124,223,102,1,101,Urban,130095,31554,2,109,645,220,6,376,86,808,15,1,602,80,686,Urban,95700,0,95700,1800,44700,35500,3800,181500,130200,0,130200,2300,59300,43700,6100,241600,294700,0,47000,26900,73900,14300,0,10500,24800,1100
+15839,Gujarat, Banas Kantha ,446697,273100,193902,0,0,0,0,-100,-100,-100,-300,81,820,76,155,4,325,29,303,153,855,Urban,81820,23315,822,210,124,9,855,46,812,8,370,20,284,Urban,13000,0,13000,1900,251600,151700,600,418800,13500,0,13500,1800,324500,177200,600,517600,1044900,110700,53200,31000,84200,65100,0,17800,82900,0,27300,27300,739800,985000,245200
+15840,Gujarat, Bharuch ,521397,117700,131402,0,0,0,0,-100,-100,-100,-300,1,18,70,1,15,28,2,193,26,169,102,552,Urban,118070,18267,1,107,890,196,11,166,83,650,28,1,892,80,794,Urban,54400,0,54400,1600,8400,54200,400,119000,56100,0,56100,1700,9300,57100,400,124600,524700,24500,72600,19800,92400,16300,0,35500,51800,0,40500
+15841,Gujarat, Bhavnagar ,114507,76500,18292,0,0,0,0,-100,-100,-100,-300,2,38,737,2,29,86,6,153,122,831,722,1,823,Urban,238737,56709,4,231,5,778,1,283,30,61,1,37,529,64,1,653,209,1,220,Urban,28500,0,28500,2000,500,201300,5900,238200,32500,0,32500,2000,500,256200,6200,297400,858000,26900,60100,99000,159100,61500
+15842,Gujarat, Dahod ,622142,216100,62457,0,0,0,0,-100,-100,-100,-300,34,875,31,677,2,901,26,27,12,232,Urban,34875,11280,349,346,23,1,351,20,786,32,514,80,114,Urban,6700,0,6700,4900,1100,73400,6400,92500,7200,0,7200,5500,1600,57800,6400,78500,371200,88400,21200,26000,47200,11300,0,2600,13900,500,6700,7200,214500,309300,94800
+15843,Gujarat, Gandhinagar ,299160,201900,167840,0,0,0,0,-100,-100,-100,-300,1,26,740,1,18,371,6,477,81,179,190,1,442,Urban,126740,28098,1,890,516,88,6,170,88,228,30,1,129,91,500,Urban,2500,0,2500,600,88800,16900,600,109400,3500,0,3500,600,118300,18900,600,141900,215900,2100,22900,1500,24400,11800,0,4900,16700,0
+15844,Gujarat, Jamnagar ,530647,210000,208652,0,0,0,0,-100,-100,-100,-300,1,94,41,1,87,473,4,101,189,182,788,1,308,Urban,194041,29537,2,358,12,232,3,696,23,691,1,18,851,354,1,602,105,1,615,Urban,14200,0,14200,1100,10900,164300,800,191300,14200,0,14200,1100,11900,230800,800,258800,1020300,45400,68500,155500,224000,76400
+15845,Gujarat, Junagadh ,22184,29964,6,0,0,0,0,-100,-100,-100,-300,1,79,735,1,75,742,3,42,90,119,158,584,Urban,179735,48672,3,663,5,711,1,408,14,446,1,3,629,94,1,370,59,683,Urban,16200,0,16200,500,500,268000,4200,289400,16200,0,16200,500,500,373400,6900,397500,880200,175900,45600,9800,55400,88900,0,8800
+15847,Gujarat, Kheda ,573955,62700,66245,0,0,0,0,-100,-100,-100,-300,1,4,2,96,39,6,687,61,156,84,975,Urban,104002,32994,1,334,396,118,6,901,59,976,14,1,697,128,444,Urban,67500,0,67500,5600,61200,74200,4100,212600,92200,0,92200,6300,84600,94500,5700,283300,394400,9600,38300,8100,46400,14600,0,2300,16900,0,18500,18500
+15848,Gujarat, Mahesana ,520242,109700,78057,0,0,0,0,-100,-100,-100,-300,1,7,867,1,2,911,3,820,98,118,80,840,Urban,107867,21295,1,124,211,104,6,812,76,728,21,1,193,17,362,Urban,20600,0,20600,1800,174700,20600,900,218600,21100,0,21100,1800,228900,20600,900,273300,439200,7200,31700,5200,36900,26900,0,4600,31500,100,11900
BIN  bamboo-client/server/.server.coffee.swp
View
Binary file not shown
3  bamboo-client/server/server.coffee
View
@@ -3,7 +3,8 @@ require = __meteor_bootstrap__.require
request = require 'request'
#bambooURL = 'http://localhost:8080'
#bambooURL = 'http://bamboo.modilabs.org/'
-bambooURL = 'http://bamboo.io/'
+#bambooURL = 'http://bamboo.io/'
+bambooURL = 'http://starscream.modilabs.org:8080/'
datasetsURL = bambooURL + '/datasets'
summaryURLf = (id,group) -> datasetsURL + '/' + id + '/summary' +
if group then '?group=' + group else ''
112 bamboo-client/server/server.coffee~
View
@@ -0,0 +1,112 @@
+root = global ? window
+require = __meteor_bootstrap__.require
+request = require 'request'
+#bambooURL = 'http://localhost:8080'
+#bambooURL = 'http://bamboo.modilabs.org/'
+bambooURL = 'http://bamboo.io/'
+datasetsURL = bambooURL + '/datasets'
+summaryURLf = (id,group) -> datasetsURL + '/' + id + '/summary' +
+ if group then '?group=' + group else ''
+
+schemaURLf = (id) -> datasetsURL + '/' + id + '/info'
+
+#Note: methods can live anywhere, regardless of server or client
+Meteor.methods(
+ register_dataset: (url) ->
+ if url is null
+ console.log "null url! discard!"
+ else
+ console.log "server received url " + url
+ unless Datasets.findOne({url: url})
+ post_options =
+ uri: datasetsURL
+ method: 'POST'
+ form: {url: url}
+ request post_options, (e, b, response) ->
+ Fiber(->
+ unless Datasets.findOne({url: url})
+ Datasets.insert
+ bambooID: JSON.parse(response).id
+ url: url
+ cached_at: Date.now()
+ Meteor.call('insert_schema', url)
+ ).run()
+
+ insert_schema: (datasetURL) ->
+ dataset = Datasets.findOne(url: datasetURL)
+ if !(dataset)
+ console.log "no dataset yet, get your schema dataset first"
+ else
+ datasetID = dataset._id
+ bambooID = dataset.bambooID
+
+ # TODO: not sure about the updated time or created time
+ if Schemas.findOne(datasetID: datasetID)
+ console.log("schema with datasetID " + datasetID +
+ " and bambooID " + bambooID + " is already cached")
+ else
+ request.get(schemaURLf(bambooID), (error, body, response) ->
+ if error
+ console.log error
+ else
+ obj = JSON.parse(response)
+ updateTime = obj['updated_at']
+ createTime = obj['created_at']
+ schema = obj['schema']
+ res =
+ updateTime : updateTime
+ createTime : createTime
+ schema : schema
+ datasetID : datasetID
+ datasetURL : datasetURL
+ Fiber( -> Schemas.insert res).run()
+ )
+
+ summarize_by_group: (obj) ->
+ # tease out individual summary objects from bamboo output + store
+ [datasetURL, groupkey] = obj
+ dataset = Datasets.findOne(url: datasetURL)
+ # check if dataset valid
+ if !(dataset)
+ console.log datasetURL, groupkey
+ console.log "no dataset yet, get your summary dataset first"
+ else
+ datasetID = dataset._id
+ bambooID = dataset.bambooID
+ if Summaries.findOne(datasetID: datasetID, groupKey: groupkey)
+ console.log("summary with datasetID " + datasetID +
+ " and groupkey " + groupkey + " is already cached")
+ else
+ groupKey = groupkey
+ request.get(summaryURLf(bambooID, groupkey), (error, body, response) ->
+ if error
+ console.log error
+ else
+ obj = JSON.parse(response)
+ if groupKey is ""
+ for field of obj
+ res=
+ groupKey: groupKey
+ groupVal: groupKey
+ data: obj[field]["summary"]
+ name:field
+ datasetID: datasetID
+ datasetURL: datasetURL
+ Fiber( -> Summaries.insert res).run()
+ else
+ if obj["error"]
+ console.log "error on group_by: "+obj['error']
+ else
+ for groupkey of obj
+ for groupval of obj[groupkey]
+ for field of obj[groupkey][groupval]
+ res=
+ groupKey: groupkey
+ groupVal: groupval
+ data: obj[groupkey][groupval][field]["summary"]
+ name:field
+ datasetID: datasetID
+ datasetURL: datasetURL
+ Fiber( -> Summaries.insert res).run()
+ )
+)

No commit comments for this range

Something went wrong with that request. Please try again.