diff --git a/README.md b/README.md index ff3a9ac..9d66f91 100644 --- a/README.md +++ b/README.md @@ -102,19 +102,10 @@ Webapp will run on 127.0.0.1:8080 ### Some screenshots Some screenshots can be old, and can contain errors. -![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis00_new.png "goBlockchainDataAnalysis") - ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis00.png "goBlockchainDataAnalysis") -![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis06.gif "goBlockchainDataAnalysis") - -![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis05.png "goBlockchainDataAnalysis") - - ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis01.png "goBlockchainDataAnalysis") - ![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis02.png "goBlockchainDataAnalysis") - -![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis04.png "goBlockchainDataAnalysis") +![goBlockchainDataAnalysis](https://raw.githubusercontent.com/arnaucode/goBlockchainDataAnalysis/master/screenshots/goBlockchainDataAnalysis03.gif "goBlockchainDataAnalysis") diff --git a/mongoModels.go b/mongoModels.go index a733064..f9ed778 100644 --- a/mongoModels.go +++ b/mongoModels.go @@ -98,7 +98,10 @@ type SankeyModel struct { Nodes []SankeyNodeModel `json:"nodes"` Links []SankeyLinkModel `json:"links"` } - +type ChartCountFloat64Model struct { + Elem float64 `json:"elem"` + Count int `json:"count"` +} type ChartCountModel struct { Elem int `json:"elem"` Count int `json:"count"` diff --git a/screenshots/goBlockchainDataAnalysis00.png b/screenshots/goBlockchainDataAnalysis00.png index be076dd..0cd308c 100644 Binary files a/screenshots/goBlockchainDataAnalysis00.png and b/screenshots/goBlockchainDataAnalysis00.png differ diff --git a/screenshots/goBlockchainDataAnalysis00_new.png b/screenshots/goBlockchainDataAnalysis00_new.png deleted file mode 100644 index a210cb2..0000000 Binary files a/screenshots/goBlockchainDataAnalysis00_new.png and /dev/null differ diff --git a/screenshots/goBlockchainDataAnalysis01.png b/screenshots/goBlockchainDataAnalysis01.png index a0a81b2..dfc2b3b 100644 Binary files a/screenshots/goBlockchainDataAnalysis01.png and b/screenshots/goBlockchainDataAnalysis01.png differ diff --git a/screenshots/goBlockchainDataAnalysis02.png b/screenshots/goBlockchainDataAnalysis02.png index 56dc4e5..729036b 100644 Binary files a/screenshots/goBlockchainDataAnalysis02.png and b/screenshots/goBlockchainDataAnalysis02.png differ diff --git a/screenshots/goBlockchainDataAnalysis03.gif b/screenshots/goBlockchainDataAnalysis03.gif new file mode 100644 index 0000000..5e6973b Binary files /dev/null and b/screenshots/goBlockchainDataAnalysis03.gif differ diff --git a/screenshots/goBlockchainDataAnalysis04.png b/screenshots/goBlockchainDataAnalysis04.png deleted file mode 100644 index d3eb94c..0000000 Binary files a/screenshots/goBlockchainDataAnalysis04.png and /dev/null differ diff --git a/screenshots/goBlockchainDataAnalysis05.png b/screenshots/goBlockchainDataAnalysis05.png deleted file mode 100644 index 833983c..0000000 Binary files a/screenshots/goBlockchainDataAnalysis05.png and /dev/null differ diff --git a/screenshots/goBlockchainDataAnalysis06.gif b/screenshots/goBlockchainDataAnalysis06.gif deleted file mode 100644 index a5dcef6..0000000 Binary files a/screenshots/goBlockchainDataAnalysis06.gif and /dev/null differ diff --git a/screenshots/new/goBlockchainDataAnalysis00.png b/screenshots/new/goBlockchainDataAnalysis00.png deleted file mode 100644 index 0cd308c..0000000 Binary files a/screenshots/new/goBlockchainDataAnalysis00.png and /dev/null differ diff --git a/screenshots/new/goBlockchainDataAnalysis01png b/screenshots/new/goBlockchainDataAnalysis01png deleted file mode 100644 index 729036b..0000000 Binary files a/screenshots/new/goBlockchainDataAnalysis01png and /dev/null differ diff --git a/screenshots/new/goBlockchainDataAnalysis02.png b/screenshots/new/goBlockchainDataAnalysis02.png deleted file mode 100644 index dfc2b3b..0000000 Binary files a/screenshots/new/goBlockchainDataAnalysis02.png and /dev/null differ diff --git a/serverRoutes.go b/serverRoutes.go index 6ecc6b0..4b1a482 100644 --- a/serverRoutes.go +++ b/serverRoutes.go @@ -124,6 +124,12 @@ var routes = Routes{ "/last7dayhour", GetLast7DayHourAnalysis, }, + Route{ + "GetLastMonthsAnalysis", + "Get", + "/lastmonths/{count}", + GetLastMonthsAnalysis, + }, Route{ "GetAddressTimeChart", "GET", @@ -672,6 +678,50 @@ func GetLast7DayHourAnalysis(w http.ResponseWriter, r *http.Request) { check(err) fmt.Fprintln(w, string(jsonResp)) } +func GetLastMonthsAnalysis(w http.ResponseWriter, r *http.Request) { + ipFilter(w, r) + vars := mux.Vars(r) + count, err := strconv.Atoi(vars["count"]) + check(err) + fmt.Println(count) + fromDate := time.Now().AddDate(0, -count, 0) + toDate := time.Now() + + txs := []TxModel{} + err = txCollection.Find(bson.M{ + "datet": bson.M{ + "$gt": fromDate, + "$lt": toDate, + }, + }).Sort("-$natural").All(&txs) + check(err) + + //generate map with 24 hours + //hourFrequencies := map24hours() + dayFrequencies := make(map[float64]int) + for _, tx := range txs { + dayFrequencies[float64(tx.Date.Month) + float64(tx.Date.Day)/100]++ + } + var dayCount []ChartCountFloat64Model + for day, frequency := range dayFrequencies { + dayCount = append(dayCount, ChartCountFloat64Model{day, frequency}) + } + //sort by hour + sort.Slice(dayCount, func(i, j int) bool { + return dayCount[i].Elem < dayCount[j].Elem + }) + + var resp ChartAnalysisResp + for _, d := range dayCount { + resp.Labels = append(resp.Labels, strconv.FormatFloat(d.Elem, 'f', -1, 64)) + resp.Data = append(resp.Data, d.Count) + } + + //convert []resp struct to json + jsonResp, err := json.Marshal(resp) + check(err) + fmt.Fprintln(w, string(jsonResp)) +} func GetAddressTimeChart(w http.ResponseWriter, r *http.Request) { ipFilter(w, r) diff --git a/web/views/addressNetwork/addressNetwork.html b/web/views/addressNetwork/addressNetwork.html index 3278d0d..9a2de77 100644 --- a/web/views/addressNetwork/addressNetwork.html +++ b/web/views/addressNetwork/addressNetwork.html @@ -1,6 +1,6 @@
-
+

All addresses ({{addresses.length}})

@@ -17,7 +17,7 @@
-
+

Address history Network Map {{selectedAddress.id}}, BlockHeight: {{selectedAddress.group}}

diff --git a/web/views/dateAnalysis/dateAnalysis.html b/web/views/dateAnalysis/dateAnalysis.html index 1196c0d..7831d96 100644 --- a/web/views/dateAnalysis/dateAnalysis.html +++ b/web/views/dateAnalysis/dateAnalysis.html @@ -30,3 +30,15 @@
+
+
+
+
+

Last {{monthsCount}} Months Tx/Hour

+
+
+ + +
+
+
diff --git a/web/views/dateAnalysis/dateAnalysis.js b/web/views/dateAnalysis/dateAnalysis.js index 6f4dd21..f5fe9be 100644 --- a/web/views/dateAnalysis/dateAnalysis.js +++ b/web/views/dateAnalysis/dateAnalysis.js @@ -57,4 +57,20 @@ angular.module('app.dateAnalysis', ['ngRoute', 'chart.js']) }, function(data, status, headers, config) { console.log('data error'); }); + + $scope.lastmonths={ + data: [], + labels: [] + }; + $scope.monthsCount = 3; + $http.get(urlapi + 'lastmonths/' + $scope.monthsCount) + .then(function(data, status, headers, config) { + console.log('data success'); + console.log(data); + + $scope.lastmonths.data = data.data.data; + $scope.lastmonths.labels=data.data.labels; + }, function(data, status, headers, config) { + console.log('data error'); + }); });