Skip to content

Instantly share code, notes, and snippets.

@tomaszezula
Last active April 5, 2016 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszezula/ec92e342ead82c4ab2d5a0e5f1c77596 to your computer and use it in GitHub Desktop.
Save tomaszezula/ec92e342ead82c4ab2d5a0e5f1c77596 to your computer and use it in GitHub Desktop.
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
@RestController
public class QueryController {
@Autowired
private QueryAdapter queryAdapter;
@RequestMapping("/{tableName}/avg/{field1}/by/{field2}")
public Graph avg(@PathVariable String tableName,
@PathVariable String field1,
@PathVariable String field2) {
return queryAdapter
.select(field1, field2)
.from(tableName)
.aggregate(new Average(field1, field2));
}
// Endpoints for other aggregation functions: sum, count etc.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment