refactor: rename func param

This commit is contained in:
fiftin 2024-03-06 15:51:59 +01:00
parent 2af6cdf07c
commit ab90e98d3b
8 changed files with 48 additions and 62 deletions

View File

@ -29,7 +29,6 @@ var inventoryID int
var environmentID int
var templateID int
var integrationID int
var integrationExtractorID int
var integrationExtractValueID int
var integrationMatchID int

View File

@ -245,7 +245,7 @@ func addIntegration() *db.Integration {
func addIntegrationExtractValue() *db.IntegrationExtractValue {
integrationextractvalue, err := store.CreateIntegrationExtractValue(userProject.ID, db.IntegrationExtractValue{
Name: "Value",
IntegrationID: integrationExtractorID,
IntegrationID: integrationID,
ValueSource: db.IntegrationExtractBodyValue,
BodyDataType: db.IntegrationBodyDataJSON,
Key: "key",
@ -262,7 +262,7 @@ func addIntegrationExtractValue() *db.IntegrationExtractValue {
func addIntegrationMatcher() *db.IntegrationMatcher {
integrationmatch, err := store.CreateIntegrationMatcher(userProject.ID, db.IntegrationMatcher{
Name: "matcher",
IntegrationID: integrationExtractorID,
IntegrationID: integrationID,
MatchType: "body",
Method: "equals",
BodyDataType: "json",

View File

@ -35,7 +35,6 @@ const (
EventUser EventObjectType = "user"
EventView EventObjectType = "view"
EventIntegration EventObjectType = "integration"
EventIntegrationExtractor EventObjectType = "integrationextractor"
EventIntegrationExtractValue EventObjectType = "integrationextractvalue"
EventIntegrationMatcher EventObjectType = "integrationmatcher"
)

View File

@ -554,8 +554,8 @@ func (d *BoltDb) getIntegrationRefs(projectID int, objectProps db.ObjectProps, o
return
}
func (d *BoltDb) getIntegrationExtractorChildrenRefs(extractorID int, objectProps db.ObjectProps, objectID int) (refs db.IntegrationExtractorChildReferrers, err error) {
//refs.IntegrationExtractors, err = d.getReferringObjectByParentID(objectID, objectProps, extractorID, db.IntegrationExtractorProps)
func (d *BoltDb) getIntegrationExtractorChildrenRefs(integrationID int, objectProps db.ObjectProps, objectID int) (refs db.IntegrationExtractorChildReferrers, err error) {
//refs.IntegrationExtractors, err = d.getReferringObjectByParentID(objectID, objectProps, integrationID, db.IntegrationExtractorProps)
//if err != nil {
// return
//}

View File

@ -55,17 +55,17 @@ Integration Extractors
/*
Integration ExtractValue
*/
func (d *BoltDb) GetIntegrationExtractValuesByExtractorID(extractorID int) (values []db.IntegrationExtractValue, err error) {
err = d.getObjects(extractorID, db.IntegrationExtractValueProps, db.RetrieveQueryParams{}, nil, &values)
func (d *BoltDb) GetIntegrationExtractValuesByExtractorID(integrationID int) (values []db.IntegrationExtractValue, err error) {
err = d.getObjects(integrationID, db.IntegrationExtractValueProps, db.RetrieveQueryParams{}, nil, &values)
return values, err
}
func (d *BoltDb) DeleteIntegrationExtractValue(projectID int, valueID int, extractorID int) error {
func (d *BoltDb) DeleteIntegrationExtractValue(projectID int, valueID int, integrationID int) error {
return d.deleteObject(projectID, db.IntegrationExtractValueProps, intObjectID(valueID), nil)
}
func (d *BoltDb) GetIntegrationMatchersByExtractorID(extractorID int) (matchers []db.IntegrationMatcher, err error) {
err = d.getObjects(extractorID, db.IntegrationMatcherProps, db.RetrieveQueryParams{}, nil, &matchers)
func (d *BoltDb) GetIntegrationMatchersByExtractorID(integrationID int) (matchers []db.IntegrationMatcher, err error) {
err = d.getObjects(integrationID, db.IntegrationMatcherProps, db.RetrieveQueryParams{}, nil, &matchers)
return matchers, err
}
@ -82,7 +82,7 @@ func (d *BoltDb) CreateIntegrationExtractValue(projectId int, value db.Integrati
}
func (d *BoltDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQueryParams, extractorID int) (values []db.IntegrationExtractValue, err error) {
func (d *BoltDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQueryParams, integrationID int) (values []db.IntegrationExtractValue, err error) {
values = make([]db.IntegrationExtractValue, 0)
var allValues []db.IntegrationExtractValue
@ -93,7 +93,7 @@ func (d *BoltDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQu
}
for _, v := range allValues {
if v.IntegrationID == extractorID {
if v.IntegrationID == integrationID {
values = append(values, v)
}
}
@ -101,7 +101,7 @@ func (d *BoltDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQu
return
}
func (d *BoltDb) GetIntegrationExtractValue(projectID int, valueID int, extractorID int) (value db.IntegrationExtractValue, err error) {
func (d *BoltDb) GetIntegrationExtractValue(projectID int, valueID int, integrationID int) (value db.IntegrationExtractValue, err error) {
err = d.getObject(projectID, db.IntegrationExtractValueProps, intObjectID(valueID), &value)
return value, err
}
@ -116,7 +116,7 @@ func (d *BoltDb) UpdateIntegrationExtractValue(projectID int, integrationExtract
return d.updateObject(projectID, db.IntegrationExtractValueProps, integrationExtractValue)
}
func (d *BoltDb) GetIntegrationExtractValueRefs(projectID int, valueID int, extractorID int) (db.IntegrationExtractorChildReferrers, error) {
func (d *BoltDb) GetIntegrationExtractValueRefs(projectID int, valueID int, integrationID int) (db.IntegrationExtractorChildReferrers, error) {
return d.getIntegrationExtractorChildrenRefs(projectID, db.IntegrationExtractValueProps, valueID)
}
@ -133,7 +133,7 @@ func (d *BoltDb) CreateIntegrationMatcher(projectID int, matcher db.IntegrationM
return newMatcher.(db.IntegrationMatcher), err
}
func (d *BoltDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryParams, extractorID int) (matchers []db.IntegrationMatcher, err error) {
func (d *BoltDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryParams, integrationID int) (matchers []db.IntegrationMatcher, err error) {
matchers = make([]db.IntegrationMatcher, 0)
var allMatchers []db.IntegrationMatcher
@ -144,7 +144,7 @@ func (d *BoltDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryPa
}
for _, v := range allMatchers {
if v.IntegrationID == extractorID {
if v.IntegrationID == integrationID {
matchers = append(matchers, v)
}
}
@ -152,9 +152,9 @@ func (d *BoltDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryPa
return
}
func (d *BoltDb) GetIntegrationMatcher(projectID int, matcherID int, extractorID int) (matcher db.IntegrationMatcher, err error) {
func (d *BoltDb) GetIntegrationMatcher(projectID int, matcherID int, integrationID int) (matcher db.IntegrationMatcher, err error) {
var matchers []db.IntegrationMatcher
matchers, err = d.GetIntegrationMatchers(projectID, db.RetrieveQueryParams{}, extractorID)
matchers, err = d.GetIntegrationMatchers(projectID, db.RetrieveQueryParams{}, integrationID)
for _, v := range matchers {
if v.ID == matcherID {
@ -175,23 +175,23 @@ func (d *BoltDb) UpdateIntegrationMatcher(projectID int, integrationMatcher db.I
return d.updateObject(projectID, db.IntegrationMatcherProps, integrationMatcher)
}
func (d *BoltDb) DeleteIntegrationMatcher(projectID int, matcherID int, extractorID int) error {
func (d *BoltDb) DeleteIntegrationMatcher(projectID int, matcherID int, integrationID int) error {
return d.deleteObject(projectID, db.IntegrationMatcherProps, intObjectID(matcherID), nil)
}
func (d *BoltDb) DeleteIntegration(projectID int, integrationID int) error {
extractors, err := d.GetIntegrationMatchers(projectID, db.RetrieveQueryParams{}, integrationID)
matchers, err := d.GetIntegrationMatchers(projectID, db.RetrieveQueryParams{}, integrationID)
if err != nil {
return err
}
for extractor := range extractors {
d.DeleteIntegrationMatcher(projectID, extractors[extractor].ID, integrationID)
for m := range matchers {
d.DeleteIntegrationMatcher(projectID, matchers[m].ID, integrationID)
}
return d.deleteObject(projectID, db.IntegrationProps, intObjectID(integrationID), nil)
}
func (d *BoltDb) GetIntegrationMatcherRefs(projectID int, matcherID int, extractorID int) (db.IntegrationExtractorChildReferrers, error) {
func (d *BoltDb) GetIntegrationMatcherRefs(projectID int, matcherID int, integrationID int) (db.IntegrationExtractorChildReferrers, error) {
return d.getIntegrationExtractorChildrenRefs(projectID, db.IntegrationMatcherProps, matcherID)
}

View File

@ -733,7 +733,7 @@ func (d *SqlDb) GetReferencesForForeignKey(objectProps db.ObjectProps, objectID
// Find Object Referrers for objectID based on referring column taken from referringObjectProps
// Example:
// GetObjectReferences(db.WebhookMatchers, db.WebhookExtractorProps, extractorID)
// GetObjectReferences(db.WebhookMatchers, db.WebhookExtractorProps, integrationID)
func (d *SqlDb) GetObjectReferences(objectProps db.ObjectProps, referringObjectProps db.ObjectProps, objectID int) (referringObjs []db.ObjectReferrer, err error) {
referringObjs = make([]db.ObjectReferrer, 0)

View File

@ -92,11 +92,11 @@ func (d *SqlDb) UpdateIntegration(integration db.Integration) error {
return err
}
func (d *SqlDb) GetIntegrationExtractValuesByExtractorID(extractorID int) (values []db.IntegrationExtractValue, err error) {
func (d *SqlDb) GetIntegrationExtractValuesByExtractorID(integrationID int) (values []db.IntegrationExtractValue, err error) {
var sqlError error
query, args, sqlError := squirrel.Select("v.*").
From("project__integration_extract_value as v").
Where(squirrel.Eq{"integration_id": extractorID}).
Where(squirrel.Eq{"integration_id": integrationID}).
OrderBy("v.id").
ToSql()
@ -109,11 +109,11 @@ func (d *SqlDb) GetIntegrationExtractValuesByExtractorID(extractorID int) (value
return values, err
}
func (d *SqlDb) GetIntegrationMatchersByExtractorID(extractorID int) (matchers []db.IntegrationMatcher, err error) {
func (d *SqlDb) GetIntegrationMatchersByExtractorID(integrationID int) (matchers []db.IntegrationMatcher, err error) {
var sqlError error
query, args, sqlError := squirrel.Select("m.*").
From("project__integration_matcher as m").
Where(squirrel.Eq{"integration_id": extractorID}).
Where(squirrel.Eq{"integration_id": integrationID}).
OrderBy("m.id").
ToSql()
@ -126,36 +126,36 @@ func (d *SqlDb) GetIntegrationMatchersByExtractorID(extractorID int) (matchers [
return matchers, err
}
//func (d *SqlDb) DeleteIntegrationExtractor(projectID int, extractorID int, integrationID int) error {
// values, err := d.GetIntegrationExtractValuesByExtractorID(extractorID)
//func (d *SqlDb) DeleteIntegrationExtractor(projectID int, integrationID int, integrationID int) error {
// values, err := d.GetIntegrationExtractValuesByExtractorID(integrationID)
// if err != nil && !strings.Contains(err.Error(), "no rows in result set") {
// return err
// }
//
// for value := range values {
//
// err = d.DeleteIntegrationExtractValue(0, values[value].ID, extractorID)
// err = d.DeleteIntegrationExtractValue(0, values[value].ID, integrationID)
// if err != nil && !strings.Contains(err.Error(), "no rows in result set") {
// log.Error(err)
// return err
// }
// }
//
// matchers, errExtractor := d.GetIntegrationMatchersByExtractorID(extractorID)
// matchers, errExtractor := d.GetIntegrationMatchersByExtractorID(integrationID)
// if errExtractor != nil && !strings.Contains(errExtractor.Error(), "no rows in result set") {
// log.Error(errExtractor)
// return errExtractor
// }
//
// for matcher := range matchers {
// err = d.DeleteIntegrationMatcher(0, matchers[matcher].ID, extractorID)
// err = d.DeleteIntegrationMatcher(0, matchers[matcher].ID, integrationID)
// if err != nil && !strings.Contains(err.Error(), "no rows in result set") {
// log.Error(err)
// return err
// }
// }
//
// return d.deleteObjectByReferencedID(integrationID, db.IntegrationProps, db.IntegrationExtractorProps, extractorID)
// return d.deleteObjectByReferencedID(integrationID, db.IntegrationProps, db.IntegrationExtractorProps, integrationID)
//}
//
//func (d *SqlDb) UpdateIntegrationExtractor(projectID int, integrationExtractor db.IntegrationExtractor) error {
@ -201,9 +201,9 @@ func (d *SqlDb) CreateIntegrationExtractValue(projectId int, value db.Integratio
return
}
func (d *SqlDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQueryParams, extractorID int) ([]db.IntegrationExtractValue, error) {
func (d *SqlDb) GetIntegrationExtractValues(projectID int, params db.RetrieveQueryParams, integrationID int) ([]db.IntegrationExtractValue, error) {
var values []db.IntegrationExtractValue
err := d.getObjectsByReferrer(extractorID, db.IntegrationProps, db.IntegrationExtractValueProps, params, &values)
err := d.getObjectsByReferrer(integrationID, db.IntegrationProps, db.IntegrationExtractValueProps, params, &values)
return values, err
}
@ -214,7 +214,7 @@ func (d *SqlDb) GetAllIntegrationExtractValues() (values []db.IntegrationExtract
return
}
func (d *SqlDb) GetIntegrationExtractValue(projectID int, valueID int, extractorID int) (value db.IntegrationExtractValue, err error) {
func (d *SqlDb) GetIntegrationExtractValue(projectID int, valueID int, integrationID int) (value db.IntegrationExtractValue, err error) {
query, args, err := squirrel.Select("v.*").
From("project__integration_extract_value as v").
Where(squirrel.Eq{"id": valueID}).
@ -230,13 +230,13 @@ func (d *SqlDb) GetIntegrationExtractValue(projectID int, valueID int, extractor
return value, err
}
func (d *SqlDb) GetIntegrationExtractValueRefs(projectID int, valueID int, extractorID int) (refs db.IntegrationExtractorChildReferrers, err error) {
refs.Integrations, err = d.GetObjectReferences(db.IntegrationProps, db.IntegrationExtractValueProps, extractorID)
func (d *SqlDb) GetIntegrationExtractValueRefs(projectID int, valueID int, integrationID int) (refs db.IntegrationExtractorChildReferrers, err error) {
refs.Integrations, err = d.GetObjectReferences(db.IntegrationProps, db.IntegrationExtractValueProps, integrationID)
return
}
func (d *SqlDb) DeleteIntegrationExtractValue(projectID int, valueID int, extractorID int) error {
return d.deleteObjectByReferencedID(extractorID, db.IntegrationProps, db.IntegrationExtractValueProps, valueID)
func (d *SqlDb) DeleteIntegrationExtractValue(projectID int, valueID int, integrationID int) error {
return d.deleteObjectByReferencedID(integrationID, db.IntegrationProps, db.IntegrationExtractValueProps, valueID)
}
func (d *SqlDb) UpdateIntegrationExtractValue(projectID int, integrationExtractValue db.IntegrationExtractValue) error {
@ -288,10 +288,10 @@ func (d *SqlDb) CreateIntegrationMatcher(projectID int, matcher db.IntegrationMa
return
}
func (d *SqlDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryParams, extractorID int) (matchers []db.IntegrationMatcher, err error) {
func (d *SqlDb) GetIntegrationMatchers(projectID int, params db.RetrieveQueryParams, integrationID int) (matchers []db.IntegrationMatcher, err error) {
query, args, err := squirrel.Select("m.*").
From("project__integration_matcher as m").
Where(squirrel.Eq{"integration_id": extractorID}).
Where(squirrel.Eq{"integration_id": integrationID}).
OrderBy("m.id").
ToSql()
@ -312,7 +312,7 @@ func (d *SqlDb) GetAllIntegrationMatchers() (matchers []db.IntegrationMatcher, e
return
}
func (d *SqlDb) GetIntegrationMatcher(projectID int, matcherID int, extractorID int) (matcher db.IntegrationMatcher, err error) {
func (d *SqlDb) GetIntegrationMatcher(projectID int, matcherID int, integrationID int) (matcher db.IntegrationMatcher, err error) {
query, args, err := squirrel.Select("m.*").
From("project__integration_matcher as m").
Where(squirrel.Eq{"id": matcherID}).
@ -328,14 +328,14 @@ func (d *SqlDb) GetIntegrationMatcher(projectID int, matcherID int, extractorID
return matcher, err
}
func (d *SqlDb) GetIntegrationMatcherRefs(projectID int, matcherID int, extractorID int) (refs db.IntegrationExtractorChildReferrers, err error) {
func (d *SqlDb) GetIntegrationMatcherRefs(projectID int, matcherID int, integrationID int) (refs db.IntegrationExtractorChildReferrers, err error) {
refs.Integrations, err = d.GetObjectReferences(db.IntegrationProps, db.IntegrationMatcherProps, matcherID)
return
}
func (d *SqlDb) DeleteIntegrationMatcher(projectID int, matcherID int, extractorID int) error {
return d.deleteObjectByReferencedID(extractorID, db.IntegrationProps, db.IntegrationMatcherProps, matcherID)
func (d *SqlDb) DeleteIntegrationMatcher(projectID int, matcherID int, integrationID int) error {
return d.deleteObjectByReferencedID(integrationID, db.IntegrationProps, db.IntegrationMatcherProps, matcherID)
}
func (d *SqlDb) UpdateIntegrationMatcher(projectID int, integrationMatcher db.IntegrationMatcher) error {

View File

@ -1,5 +1,5 @@
<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
<div v-if="extractor != null">
<div v-if="integration != null">
<v-toolbar flat>
<v-app-bar-nav-icon @click="showDrawer()"></v-app-bar-nav-icon>
@ -40,12 +40,6 @@ export default {
url: `/api/project/${this.projectId}/integrations/${this.integrationId}`,
responseType: 'json',
})).data;
this.extractor = (await axios({
method: 'get',
url: `/api/project/${this.projectId}/integrations/${this.integrationId}`,
responseType: 'json',
})).data;
},
computed: {
@ -61,12 +55,6 @@ export default {
}
return this.$route.params.integrationId;
},
extractorId() {
if (/^-?\d+$/.test(this.$route.params.extractorId)) {
return parseInt(this.$route.params.extractorId, 10);
}
return this.$route.params.extractorId;
},
},
methods: {
allowActions() {
@ -76,7 +64,7 @@ export default {
return [];
},
getItemsUrl() {
return `/api/project/${this.projectId}/integrations/${this.integrationId}/extractors`;
return `/api/project/${this.projectId}/integrations`;
},
getSingleItemUrl() {
return `/api/project/${this.projectId}/integrations/${this.integrationId}`;