Skip to content
Browse files

Fixed a timezone bug, along with another one concerning utc/local

time.
  • Loading branch information...
1 parent f9dc73f commit 3ea95f139b2a427263c73c7d6b44068a990ba39a @zmaril zmaril committed Jun 19, 2012
View
11 country-dashboard/data/combine.coffee
@@ -129,10 +129,11 @@ load_utc = (data)->
[country, absolute, total, relative, day, hour] = item
relative = +relative
absolute = +absolute
- hour = (hour-1) % 6
+ day = +day
+ day = (day+6) % 7
if country is "country" or country.length is 0 then return
- data[country].total = total if not data[country].total?
+ data[country].total = total
#Init empty arrays to deal with sparse arrays
if not data[country]["utc_hours"]?
@@ -183,6 +184,7 @@ load_local = (data)->
_.map(rawData,addToData)
fs.writeFileSync("working_data.json",JSON.stringify(data))
+ calculate_global(data)
load_sorted_by_category(data)
)
.on('error',(error)->
@@ -205,14 +207,15 @@ load_sorted_by_category = (data)->
fs.writeFileSync("sorted.json",JSON.stringify(sorted_by_category))
- calculate_global(data)
+
calculate_global = (data)->
global = {}
all_hours = []
for country,hour of data
- all_hours.push hour.hours
+ d = data[country].local_hours
+ all_hours.push(d) if d?
sum = _.reduce(_.flatten(all_hours),(a,b)-> a+b)
tmp = _.reduce all_hours, (matrix_a,matrix_b)->
View
14 country-dashboard/data/combine.js
@@ -137,9 +137,10 @@ load_utc = function(data) {
country = item[0], absolute = item[1], total = item[2], relative = item[3], day = item[4], hour = item[5];
relative = +relative;
absolute = +absolute;
- hour = (hour - 1) % 6;
+ day = +day;
+ day = (day + 6) % 7;
if (country === "country" || country.length === 0) return;
- if (!(data[country].total != null)) data[country].total = total;
+ data[country].total = total;
if (!(data[country]["utc_hours"] != null)) {
zero = function() {
var i, _results;
@@ -210,6 +211,7 @@ load_local = function(data) {
};
_.map(rawData, addToData);
fs.writeFileSync("working_data.json", JSON.stringify(data));
+ calculate_global(data);
return load_sorted_by_category(data);
}).on('error', function(error) {
return console.log(error.message);
@@ -248,17 +250,17 @@ load_sorted_by_category = function(data) {
sorted_by_category.absolute[category][sub] = c;
}
}
- fs.writeFileSync("sorted.json", JSON.stringify(sorted_by_category));
- return calculate_global(data);
+ return fs.writeFileSync("sorted.json", JSON.stringify(sorted_by_category));
};
calculate_global = function(data) {
- var all_hours, country, global, hour, sum, tmp;
+ var all_hours, country, d, global, hour, sum, tmp;
global = {};
all_hours = [];
for (country in data) {
hour = data[country];
- all_hours.push(hour.hours);
+ d = data[country].local_hours;
+ if (d != null) all_hours.push(d);
}
sum = _.reduce(_.flatten(all_hours), function(a, b) {
return a + b;
View
2 country-dashboard/data/global.json
@@ -1 +1 @@
-{"reduced":[[25405,21554,18465,16166,14968,15359,17209,20660,25840,31676,35775,37335,38089,38571,39114,39409,39299,38823,37988,37150,36440,35973,34948,32913],[29845,25899,21947,19087,17627,17805,19801,23434,28725,34488,37938,39352,39755,40141,40578,40721,40534,39848,38987,38224,37558,37164,36181,34247],[31110,26903,22988,19927,18364,18427,20305,24050,29142,34913,38435,39996,40504,40708,40996,41329,41139,40419,39472,38619,37820,37229,36350,34383],[31343,27234,23212,20116,18538,18620,20409,23935,29096,34861,38382,40080,40751,40953,41289,41505,41194,40479,39747,38869,37975,37610,36564,34487],[31660,27602,23776,20813,19098,18986,20830,24356,29348,35109,38606,40055,40389,40029,40759,40950,40537,39601,38455,37165,36191,35523,34586,32740],[30079,26663,22840,19802,17890,17386,18554,21045,24859,29949,33316,35002,35776,35998,36227,36157,35638,34664,33612,32570,31602,31144,30547,29059],[26817,23481,20070,17110,15299,14677,15790,18037,21145,24454,27225,29002,29900,30587,30971,31260,30972,30474,30174,30074,30180,30231,29621,28120]]}
+{"reduced":[[2526.632780705699,2035.9585499320003,1676.8963414933003,1412.1741398893,1297.4618786652004,1369.6543406066003,1603.8207892205003,2028.8246634849997,2821.797220431,3941.991872131299,4921.787254665897,5427.736561487298,5636.542705214703,5758.9233245414,5916.523725058101,6024.070370690399,5918.5343245046,5584.720562929701,5152.8821230263,4650.6024094871,4418.9414976635,4396.777641546201,4256.2898126990995,3845.5712515300006],[3242.3767544481007,2639.1588461528995,2166.534696392801,1854.4457511787,1705.6847316326998,1726.7956564526005,1966.8032009680994,2483.6810928642,3437.7781388789986,4773.095429384,5781.402833320602,6259.848580717301,6378.633276568498,6462.951199436198,6597.3632231491,6678.547911328196,6522.295501175599,6143.2893241336,5620.4829240115005,5090.060038916797,4865.1305814216,4847.233673781099,4703.0626378143015,4262.525084579199],[3584.2564262623982,2915.155689937399,2387.3990374694995,2023.1340930462002,1833.9017235257004,1843.5487005930997,2067.6416177943997,2597.0696787263996,3547.0136254098998,4863.880258540799,5878.989915996602,6351.686194986699,6474.7135071312005,6547.2545550053,6667.559005213697,6736.9893266592,6586.6562246952035,6170.570767013299,5670.8448012098,5130.189222965902,4909.243205700999,4909.764261558802,4792.222860598,4353.3149063089],[3683.7918168242004,3010.1899513268013,2460.756077830502,2067.0063722671,1871.8851610793004,1884.7559617649997,2080.869360544599,2594.6644038396,3548.411424971199,4811.673833507499,5841.8958718866,6372.6266530084,6534.890794385299,6612.156746341698,6743.876031946598,6806.312724497899,6620.505662221795,6208.119941445198,5677.323546224102,5141.861590848398,4919.716307387498,4926.240106807,4805.088887675898,4370.7921166285005],[3727.1562008202,3055.0679837410994,2508.982606294899,2113.1294719864,1895.069178219,1873.2030274991007,2069.7242397094005,2564.9680979826994,3486.799663053099,4783.1566662549985,5763.678264297703,6221.670015426,6267.336729309798,6197.908049392999,6381.366053207397,6412.781616922402,6193.9910458312,5731.216975144299,5134.1527041685,4591.3232759404,4344.439990489201,4312.001412941198,4228.6887549862,3878.5286211931984],[3351.3159569394993,2765.932191241899,2266.4690712336997,1896.3421084646002,1663.7038211170002,1571.720464153399,1641.3080956268998,1877.7064666211998,2343.2942051175005,3010.2652958949025,3578.0363279480002,3848.6449136384003,3898.321901801799,3900.497549900402,3914.9205812963996,3894.443887028099,3782.9667939269984,3592.7386820078004,3405.858615373399,3262.1845134895007,3252.1547606673007,3275.7431920186987,3232.5682700135,2979.736155845101],[2562.5381618357005,2086.2980198268006,1682.2890688516995,1366.7755741836,1191.047892707,1149.9363198620997,1256.3948051479997,1498.3665343158,1851.0708047391001,2285.9558161983014,2672.0091074373013,2908.556173300901,3026.075060613101,3106.0239157541987,3168.9858324514994,3207.3822786731007,3164.524227749601,3077.061196623301,3038.3626900526,3072.2919913349992,3195.2284206863005,3304.668014467201,3273.0678252516,3008.861698438301]]}
View
2 country-dashboard/data/working_data.json
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 country-dashboard/js/compare.coffee
@@ -39,7 +39,7 @@ updateActivityData = ()->
tmp = _.chain(data.working[c].local_hours)
.flatten().value()
- instance = _.map(tmp,(d)-> d/d3.sum(tmp))
+ instance = _.map(tmp,(d)-> d/data.working[c].total)
enumerated = ({x: i*60*60, y: instance[i]} for i in _.range(instance.length))
data.activity.normal.push(
data: enumerated
View
2 country-dashboard/js/compare.js
@@ -65,7 +65,7 @@ updateActivityData = function() {
});
tmp = _.chain(data.working[c].local_hours).flatten().value();
instance = _.map(tmp, function(d) {
- return d / d3.sum(tmp);
+ return d / data.working[c].total;
});
enumerated = (function() {
var _j, _len2, _ref, _results;
View
3 country-dashboard/js/watch.coffee
@@ -101,7 +101,7 @@ createWatchWeek = ()->
hour = h%24
"#{day}, #{hour}:00-#{(hour+1)%24}:00"
),
- yFormatter: (y)-> "#{y} total workers online "
+ yFormatter: (y)-> "#{Math.round(y)} total workers online "
})
createWatchMap = ()->
@@ -203,6 +203,7 @@ updateNameMap = ()->
country = d.properties.name
percent = data.watch.relative[country]?[watch.hour]
number = data.watch.absolute[country]?[watch.hour]
+ console.log(percent,number) if country is "Russia"
if percent and number > 10
if not watch.abs_q
watch.rscale(percent)
View
3 country-dashboard/js/watch.js
@@ -124,7 +124,7 @@ createWatchWeek = function() {
return "" + day + ", " + hour + ":00-" + ((hour + 1) % 24) + ":00";
}),
yFormatter: function(y) {
- return "" + y + " total workers online ";
+ return "" + (Math.round(y)) + " total workers online ";
}
});
};
@@ -220,6 +220,7 @@ updateNameMap = function() {
country = d.properties.name;
percent = (_ref = data.watch.relative[country]) != null ? _ref[watch.hour] : void 0;
number = (_ref2 = data.watch.absolute[country]) != null ? _ref2[watch.hour] : void 0;
+ if (country === "Russia") console.log(percent, number);
if (percent && number > 10) {
if (!watch.abs_q) {
return watch.rscale(percent);

0 comments on commit 3ea95f1

Please sign in to comment.
Something went wrong with that request. Please try again.