Skip to content

Commit

Permalink
Merge pull request #11 from PavelPolyakov/master
Browse files Browse the repository at this point in the history
The backend works only after the stated changes
  • Loading branch information
fradinni committed Feb 20, 2015
2 parents e64ffbf + e110dcd commit 4d1febb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ git clone https://github.com/fradinni/nodejs-statsd-mysql-backend.git
```
You should have a new directory called 'nodejs-statsd-mysql-backend' just next to the Statsd directory.

It could be required to execute the next commands:
```
npm install mysql
npm install sequence
```

## Configuration
Edit Statsd configuraton file and add mysql-backend configuration.

Expand Down
10 changes: 8 additions & 2 deletions engines/countersEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ MySQLBackendCountersEngine.prototype.buildQuerries = function(userCounters, time
* - userCounterName: Counter name
* - counterValue: Counter value
*/
querries.push("insert into `counters_statistics` select "+time_stamp+", '"+userCounterName+"' , if(max(value),max(value),0) + "+counterValue+" from `counters_statistics` where if(name = '"+userCounterName+"', 1,0) = 1 ;");

// old strategy
// querries.push("insert into `counters_statistics` select "+time_stamp+", '"+userCounterName+"' , if(max(value),max(value),0) + "+counterValue+" from `counters_statistics` where if(name = '"+userCounterName+"', 1,0) = 1 ;");

// new strategy
querries.push("INSERT INTO `counters_statistics` (`timestamp`, `name`, `value`) VALUES ("+time_stamp+", '"+userCounterName+"', "+counterValue+")");


}
}
Expand All @@ -43,4 +49,4 @@ MySQLBackendCountersEngine.prototype.buildQuerries = function(userCounters, time
exports.init = function() {
var instance = new MySQLBackendCountersEngine();
return instance;
};
};

0 comments on commit 4d1febb

Please sign in to comment.