Skip to content

Commit

Permalink
Merge pull request #367 from nexB/248-scan-errors
Browse files Browse the repository at this point in the history
Collect scan errors on the flatFile model #248
  • Loading branch information
steven-esser authored Apr 22, 2019
2 parents 7f4edc2 + 5610292 commit 033eb07
Show file tree
Hide file tree
Showing 7 changed files with 2,086 additions and 1 deletion.
7 changes: 7 additions & 0 deletions assets/app/js/controllers/scanDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,13 @@ ScanDataTable.FILE_COLUMNS =
'name': 'is_script',
'bar_chart_class': 'bar-chart-file-infos',
'visible': false
},
{
'data': 'scan_errors',
'title': 'Scan Errors',
'name': 'scan_errors',
'bar_chart_class': 'bar-chart-file-infos',
'visible': true
}
];

Expand Down
4 changes: 4 additions & 0 deletions assets/app/js/models/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const emailModel = require('./email');
const urlModel = require('./url');
const conclusionModel = require('./conclusion');
const flatFileModel = require('./flatFile');
const scanErrorModel = require('./scanError');

module.exports = function(sequelize, DataTypes) {
// Define the models
Expand All @@ -38,6 +39,7 @@ module.exports = function(sequelize, DataTypes) {
this.Email = emailModel(sequelize, DataTypes);
this.Url = urlModel(sequelize, DataTypes);
this.Conclusion = conclusionModel(sequelize, DataTypes);
this.ScanError = scanErrorModel(sequelize, DataTypes);

this.FlatFile = flatFileModel(sequelize, DataTypes);

Expand All @@ -50,6 +52,7 @@ module.exports = function(sequelize, DataTypes) {
this.File.hasMany(this.Package);
this.File.hasMany(this.Email);
this.File.hasMany(this.Url);
this.File.hasMany(this.ScanError);
this.File.hasOne(this.Conclusion);

// Include Array for queries
Expand All @@ -61,6 +64,7 @@ module.exports = function(sequelize, DataTypes) {
{ model: this.Package, separate: true },
{ model: this.Email, separate: true },
{ model: this.Url, separate: true },
{ model: this.ScanError, separate: true },
{ model: this.Conclusion }
];

Expand Down
2 changes: 2 additions & 0 deletions assets/app/js/models/flatFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module.exports = function(sequelize, DataTypes) {
is_media: DataTypes.BOOLEAN,
is_source: DataTypes.BOOLEAN,
is_script: DataTypes.BOOLEAN,
scan_errors: jsonDataType('scan_errors'),
packages_type: jsonDataType('packages_type'),
packages_namespace: jsonDataType('packages_dataspace'),
packages_name: jsonDataType('packages_name'),
Expand Down Expand Up @@ -173,6 +174,7 @@ module.exports = function(sequelize, DataTypes) {
is_media: file.is_media,
is_source: file.is_source,
is_script: file.is_script,
scan_errors: file.scan_errors,
packages_type: getValues(file.packages, 'type'),
pacages_namespace: getValues(file.packages, 'namespace'),
packages_name: getValues(file.packages, 'name'),
Expand Down
26 changes: 26 additions & 0 deletions assets/app/js/models/scanError.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
#
# Copyright (c) 2018 nexB Inc. and others. All rights reserved.
# https://nexb.com and https://github.com/nexB/scancode-workbench/
# The ScanCode Workbench software is licensed under the Apache License version 2.0.
# ScanCode is a trademark of nexB Inc.
#
# You may not use this software except in compliance with the License.
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
*/

module.exports = function(sequelize, DataTypes) {
return sequelize.define(
'scan_errors',
{
scan_error: DataTypes.STRING
},
{
timestamps: false
});
};
8 changes: 7 additions & 1 deletion assets/app/js/workbenchDB.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
#
# Copyright (c) 2017 nexB Inc. and others. All rights reserved.
# Copyright (c) 2017 - 2019 nexB Inc. and others. All rights reserved.
# https://nexb.com and https://github.com/nexB/scancode-workbench/
# The ScanCode Workbench software is licensed under the Apache License version 2.0.
# ScanCode is a trademark of nexB Inc.
Expand Down Expand Up @@ -397,6 +397,7 @@ class WorkbenchDB {
.then(() => this.db.Package.bulkCreate(this._addExtraFields(files, 'packages'), options))
.then(() => this.db.Email.bulkCreate(this._addExtraFields(files, 'emails'), options))
.then(() => this.db.Url.bulkCreate(this._addExtraFields(files, 'urls'), options))
.then(() => this.db.ScanError.bulkCreate(this._addExtraFields(files, 'scan_errors'), options))
.then(() => this.sequelize.Promise.each(files, (file) => {
if (file.conclusion) {
return this.db.Conclusion.create(file.conclusion, options);
Expand All @@ -418,6 +419,11 @@ class WorkbenchDB {
license_expression: value,
fileId: file.id
};
} else if (attribute === 'scan_errors') {
return {
scan_error: value,
fileId: file.id
};
}
value.fileId = file.id;
return value;
Expand Down
Loading

0 comments on commit 033eb07

Please sign in to comment.