Completes POCONSOLE-46. completes well test page

This commit is contained in:
Patrick McDonagh
2016-11-15 17:48:05 -06:00
parent cbf3a1b21a
commit 891458543a
7 changed files with 263 additions and 51 deletions

View File

@@ -37,7 +37,7 @@
<li ng-class="{active: Page.page() == 'cards'}"><a href="/#/cards"><i class="fa fa-folder-open-o"></i> Cards</a></li>
<li ng-class="{active: Page.page() == 'tags'}"><a href="/#/tags"><i class="fa fa-tags"></i> Tags</a></li>
<li ng-class="{active: Page.page() == 'gaugeoff'}"><a href="/#/gaugeoff"><i class="fa fa-folder-open-o"></i> Gauge Off</a></li>
<li ng-class="{active: Page.page() == 'docs'}"><a href="/#/docs"><i class="fa fa-folder-open-o"></i> Well Test</a></li>
<li ng-class="{active: Page.page() == 'welltest'}"><a href="/#/welltest"><i class="fa fa-folder-open-o"></i> Well Test</a></li>
<li ng-class="{active: Page.page() == 'docs'}"><a href="/#/docs"><i class="fa fa-folder-open-o"></i> Events</a></li>
<li ng-class="{active: Page.page() == 'docs'}"><a href="/#/docs"><i class="fa fa-folder-open-o"></i> Notes</a></li>
<li ng-class="{active: Page.page() == 'docs'}"><a href="/#/docs"><i class="fa fa-folder-open-o"></i> Docs</a></li>
@@ -79,6 +79,7 @@
<script src="js/page.factory.js"></script>
<script src="js/tags.factory.js"></script>
<script src="js/cards.factory.js"></script>
<script src="js/welltest.factory.js"></script>
<script src="js/config.controller.js"></script>
<script src="js/dashboard.controller.js"></script>
@@ -87,6 +88,7 @@
<script src="js/tags.controller.js"></script>
<script src="js/cards.controller.js"></script>
<script src="js/gaugeoff.controller.js"></script>
<script src="js/welltest.controller.js"></script>
</body>

View File

@@ -3,7 +3,7 @@ poconsole.controller('gaugeOffCtrl',function($scope, Page, $q, $http) {
Page.setPage('gaugeoff');
var getGaugeOffData = function(page_number){
var deferred = $q.defer();
$http.get('/api/gauge_off_vals?page='+page_number).success(function(data) {
$http.get('/api/gauge_off_vals?q={"order_by":[{"field":"created_on","direction":"desc"}]}&page='+ page_number).success(function(data) {
deferred.resolve(data);
});
return deferred.promise;
@@ -12,11 +12,12 @@ poconsole.controller('gaugeOffCtrl',function($scope, Page, $q, $http) {
$scope.loadGaugeOffData = function(page_number){
var getData = getGaugeOffData(page_number);
getData.then(function(d){
console.log(d);
for(var j = 0; j < d.objects.length; j++){
d.objects[j].created_on = Date.create(d.objects[j].created_on);
// console.log({'Date Before':d.objects[j].created_on});
d.objects[j].created_on = Date.create(d.objects[j].created_on + "Z", { fromUTC: true });
// console.log({'Date After':d.objects[j].created_on});
}
$scope.gauge_off_vals = d.objects.reverse();
$scope.gauge_off_vals = d.objects;
$scope.num_pages = d.total_pages;
$scope.page_list = [];
$scope.page_num = d.page;

View File

@@ -25,6 +25,9 @@ tagserver.config([
}).when('/gaugeoff', {
templateUrl: '/templates/gaugeoff.html',
controller: 'gaugeOffCtrl'
}).when('/welltest', {
templateUrl: '/templates/welltest.html',
controller: 'wellTestCtrl'
}).when('/', {
templateUrl: '/templates/dashboard.html',
controller: 'dashboardCtrl'

View File

@@ -0,0 +1,42 @@
poconsole.controller('wellTestCtrl', function($scope, $route, $http, $routeParams, Page, wellTest) {
Page.setTitle('Well Tests');
Page.setPage('welltest');
$scope.loadWellTestData = function(page_number){
var getData = wellTest.getWellTestPage(page_number);
getData.then(function(d){
for(var j = 0; j < d.objects.length; j++){
// console.log({'Date Before':d.objects[j].created_on});
d.objects[j].created_on = Date.create(d.objects[j].created_on + "Z", { fromUTC: true });
// console.log({'Date After':d.objects[j].created_on});
}
$scope.well_test_vals = d.objects;
console.log($scope.well_test_vals);
$scope.num_pages = d.total_pages;
$scope.page_list = [];
$scope.page_num = d.page;
if ($scope.page_num < $scope.num_pages){
$scope.page_num_next = $scope.page_num + 1;
} else {
$scope.page_num_next = $scope.num_pages;
}
if ($scope.page_num > 1){
$scope.page_num_prev = $scope.page_num - 1;
} else {
$scope.page_num_prev = 1;
}
for(var i = 1; i <= $scope.num_pages; i++){
$scope.page_list.push(i);
}
});
};
$scope.loadWellTestData(1);
});

View File

@@ -0,0 +1,70 @@
poconsole.factory('wellTest',function($q, $http, $log, dateConversion){
var getWellTestPage = function(page_number) {
var deferred = $q.defer();
$http.get('/api/well_test_vals?q={"order_by":[{"field":"created_on","direction":"desc"}]}&page=' + page_number).success(function(data) {
deferred.resolve(data);
});
return deferred.promise;
};
var createWellTest = function(tag){
$http.post('/api/tags', {
tag: tag.tag,
name: tag.name,
tag_class_id: parseInt(tag.tag_class_id),
device_id: parseInt(tag.device_id),
units: tag.units,
min_expected: tag.min_expected,
max_expected: tag.max_expected,
guarantee_sec: tag.guarantee_sec,
change_threshold: tag.change_threshold,
description: tag.description,
data_type_id: parseInt(tag.data_type_id)
}).success(function(data){
return data;
});
};
var updateWellTest = function(tag){
$log.info("updateTag called with "+ JSON.stringify(tag));
var put_obj = {
tag: tag.tag,
name: tag.name,
tag_class_id: parseInt(tag.tag_class_id),
device_id: parseInt(tag.device_id),
units: tag.units,
min_expected: tag.min_expected,
max_expected: tag.max_expected,
guarantee_sec: tag.guarantee_sec,
change_threshold: tag.change_threshold,
description: tag.description,
data_type_id: parseInt(tag.data_type_id)
};
console.log({id: tag._id, put_obj: put_obj});
$http.put('/api/tags/'+ tag._id, data=put_obj).success(function(data){
return data;
}).error(function(err){
$log.warn("updateTag Error: " + err);
});
};
var deleteWellTest = function(id){
var deferred = $q.defer();
var url = '/api/tags/' + id;
$http.delete(url).success(function(data) {
deferred.resolve({
data: data
});
});
return deferred.promise;
};
return {
getWellTestPage: getWellTestPage,
createWellTest: createWellTest,
deleteWellTest: deleteWellTest,
updateWellTest: updateWellTest
};
});

View File

@@ -0,0 +1,61 @@
<div class='container'>
<div class="row">
<div class="col-md-12">
<h1>Well Test Data</h1>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<div ng-if="num_pages>1" style="text-align:center;">
<ul class="pagination">
<li>
<a ng-click="loadWellTestData(page_num_prev)" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li ng-repeat="p in page_list" ng-class="{'active':p==page_num}"><a ng-click="loadWellTestData(p)">{{p}}</a></li>
<li>
<a ng-click="loadWellTestData(page_num_next)" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</ul>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Duration</th>
<th>Volume Oil</th>
<th>Volume Water</th>
<th>Volume Gas</th>
<th>Proj. Vol. Oil</th>
<th>Proj. Vol. Water</th>
<th>Proj. Vol. Gas</th>
<th>API Grav. Oil</th>
<th>Specific Grav. Water</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="test in well_test_vals">
<td nowrap>{{ test.created_on | date: 'medium' }}</td>
<td nowrap>{{ test.duration_hours }} Hours</td>
<td nowrap>{{ test.volume_oil_actual }} BBL</td>
<td nowrap>{{ test.volume_h2o_actual }} BBL</td>
<td nowrap>{{ test.volume_gas_actual }} mmcf</td>
<td nowrap>{{ test.volume_oil_projected }} BBL</td>
<td nowrap>{{ test.volume_h2o_projected }} BBL</td>
<td nowrap>{{ test.volume_gas_projected }} mmcf</td>
<td nowrap>{{ test.api_gravity_oil }}</td>
<td nowrap>{{ test.spc_gravity_h2o }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@@ -82,56 +82,89 @@ def get_data(db_table, obj_id):
# for x in test_tag:
# self.assertTrue(test_tag[x] == tag_in_db[x])
class TestStroke(unittest.TestCase):
# class TestStroke(unittest.TestCase):
# def test_insert(self):
# test_card = {
# 'stroke_type': 'normal',
# 'stroke_number': 123,
# 'surf_pos': '[0.0, 90.0, 100.0, 25.0, 0.0]',
# 'surf_lod': '[15000.0, 20000.0, 20000.0, 15000.0, 15000.0]',
# 'down_pos': '[0.0, 0.0, 100.0, 100.0, 0.0]',
# 'down_lod': '[-10000.0, -5000.0, -5000.0, -10000.0, -10000.0]'
# }
# id_added = insert_data("cards", test_card)
# print("Added tag at _id {}".format(id_added))
#
# if id_added > 0:
# stroke_in_db = get_data("cards", id_added)
# for x in test_card:
# print("testing {}: {} == {}".format(x, test_card[x], stroke_in_db[x]))
# self.assertTrue(test_card[x] == stroke_in_db[x])
# class TestGaugeOff(unittest.TestCase):
# def test_insert(self):
# test_gauge_date = {
# 'spm_average': 7.5,
# 'downhole_gross_stroke_average': 98.7,
# 'downhole_net_stroke_average': 92.1,
# 'electricity_cost_total': 10.55,
# 'fluid_level_average': 1034.5,
# 'full_card_production_total': 750.5,
# 'inflow_rate_average': 100.2,
# 'kWh_used_total': 800.23,
# 'kWh_regen_total': 105.3,
# 'lifting_cost_average': 9.34,
# 'peak_pr_load':25098.2,
# 'min_pr_load': 12125.9,
# 'percent_run': 87.4,
# 'polished_rod_hp_average': 2.345,
# 'pump_hp_average': 3.315,
# 'production_total': 517.0,
# 'pump_intake_pressure_average': 500.433,
# 'surface_stroke_length_average': 101.1,
# 'tubing_movement_average': 0.764
# }
# id_added = insert_data("gauge_off_vals", test_gauge_date)
# print("Added gauge off at _id {}".format(id_added))
#
# if id_added > 0:
# go_in_db = get_data("gauge_off_vals", id_added)
# for x in test_gauge_date:
# print("testing {}: {} == {}".format(x, test_gauge_date[x], go_in_db[x]))
# self.assertTrue(test_gauge_date[x] == go_in_db[x])
class TestWellTest(unittest.TestCase):
def test_insert(self):
test_card = {
'stroke_type': 'normal',
'stroke_number': 123,
'surf_pos': '[0.0, 90.0, 100.0, 25.0, 0.0]',
'surf_lod': '[15000.0, 20000.0, 20000.0, 15000.0, 15000.0]',
'down_pos': '[0.0, 0.0, 100.0, 100.0, 0.0]',
'down_lod': '[-10000.0, -5000.0, -5000.0, -10000.0, -10000.0]'
# duration_hours = db.Column(db.Float)
# volume_h2o_actual = db.Column(db.Float)
# volume_oil_actual = db.Column(db.Float)
# volume_gas_actual = db.Column(db.Float)
# volume_h2o_projected = db.Column(db.Float)
# volume_oil_projected = db.Column(db.Float)
# volume_gas_projected = db.Column(db.Float)
# api_gravity_oil = db.Column(db.Float)
# spc_gravity_h2o = db.Column(db.Float)
test_well_test = {
'duration_hours': 24,
'volume_h2o_actual': 1000.0,
'volume_oil_actual': 900.0,
'volume_gas_actual': 3500.0,
'volume_h2o_projected': 1200.0,
'volume_oil_projected': 700.0,
'volume_gas_projected': 3495.5,
'api_gravity_oil': 1.4,
'spc_gravity_h2o': 1.001
}
id_added = insert_data("cards", test_card)
print("Added tag at _id {}".format(id_added))
id_added = insert_data("well_test_vals", test_well_test)
print("Added well test at _id {}".format(id_added))
if id_added > 0:
stroke_in_db = get_data("cards", id_added)
for x in test_card:
print("testing {}: {} == {}".format(x, test_card[x], stroke_in_db[x]))
self.assertTrue(test_card[x] == stroke_in_db[x])
class TestGaugeOff(unittest.TestCase):
def test_insert(self):
test_gauge_date = {
'spm_average': 7.5,
'downhole_gross_stroke_average': 98.7,
'downhole_net_stroke_average': 92.1,
'electricity_cost_total': 10.55,
'fluid_level_average': 1034.5,
'full_card_production_total': 750.5,
'inflow_rate_average': 100.2,
'kWh_used_total': 800.23,
'kWh_regen_total': 105.3,
'lifting_cost_average': 9.34,
'peak_pr_load':25098.2,
'min_pr_load': 12125.9,
'percent_run': 87.4,
'polished_rod_hp_average': 2.345,
'pump_hp_average': 3.315,
'production_total': 517.0,
'pump_intake_pressure_average': 500.433,
'surface_stroke_length_average': 101.1,
'tubing_movement_average': 0.764
}
id_added = insert_data("gauge_off_vals", test_gauge_date)
print("Added tag at _id {}".format(id_added))
if id_added > 0:
go_in_db = get_data("gauge_off_vals", id_added)
for x in test_gauge_date:
print("testing {}: {} == {}".format(x, test_gauge_date[x], go_in_db[x]))
self.assertTrue(test_gauge_date[x] == go_in_db[x])
data_in_db = get_data("well_test_vals", id_added)
for x in test_well_test:
print("testing {}: {} == {}".format(x, test_well_test[x], data_in_db[x]))
self.assertTrue(test_well_test[x] == data_in_db[x])