Skip to content

Commit

Permalink
Merge pull request #476 from ARGOeu/devel
Browse files Browse the repository at this point in the history
Version 3.4.4
  • Loading branch information
themiszamani authored Sep 1, 2022
2 parents 6272a0a + 092edca commit cee7802
Show file tree
Hide file tree
Showing 16 changed files with 407 additions and 286 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [3.4.4] - 2022-09-01

### Added

* ARGO-3663 Add info on profile in which metrics are used

### Changed

* ARGO-3612 Improve fetching and caching data in probe page
* ARGO-3613 Improve fetching and caching data in metrics page
* ARGO-3614 Improve fetching and caching data on metric profiles page
* ARGO-3615 Improve fetching and caching data on aggregations profile page
* ARGO-3616 Improve fetching and caching data on thresholds profile page
* ARGO-3617 Improve fetching and caching data in users page
* ARGO-3959 Bump Django version to 3.2.15

## [3.4.3] - 2022-08-04

### Changed
Expand Down
28 changes: 15 additions & 13 deletions poem/Poem/api/internal_views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ def error_response(status_code=None, detail=''):
return Response({'detail': detail}, status=status_code)


def one_value_inline(input):
if input:
return json.loads(input)[0]
def one_value_inline(input_data):
if input_data:
return json.loads(input_data)[0]
else:
return ''


def two_value_inline(input):
def two_value_inline(input_data):
results = []

if input:
data = json.loads(input)
if input_data:
data = json.loads(input_data)

for item in data:
if len(item.split(' ')) == 1:
Expand Down Expand Up @@ -56,11 +56,11 @@ def inline_metric_for_db(data):
return ''


def two_value_inline_dict(input):
def two_value_inline_dict(input_data):
results = dict()

if input:
data = json.loads(input)
if input_data:
data = json.loads(input_data)

for item in data:
if len(item.split(' ')) == 1:
Expand Down Expand Up @@ -92,13 +92,14 @@ def sync_webapi(api, model):
if p['id'] in entries_not_indb:
if p.get('info', False):
new_entries.append(
dict(name=p['info']['name'], description=p['info'].get('description', ''),
apiid=p['id'], groupname='')
dict(name=p['info']['name'], description=p['info'].get(
'description', ''
), apiid=p['id'], groupname='')
)
else:
new_entries.append(
dict(name=p['name'], description=p.get('description', ''),
apiid=p['id'], groupname='')
apiid=p['id'], groupname='')
)

if new_entries:
Expand All @@ -107,6 +108,7 @@ def sync_webapi(api, model):

if isinstance(instance, poem_models.MetricProfiles):
services = []
description = ""
for item in data:
if item['id'] == instance.apiid:
for service in item['services']:
Expand Down Expand Up @@ -180,7 +182,7 @@ def sync_tags_webapi():
response = requests.put(
settings.WEBAPI_METRICSTAGS,
headers={"x-api-key": token.token, "Accept": "application/json"},
data=json.dumps(data2send)
data=json.dumps(sorted(data2send, key=lambda d: d["name"]))
)

if not response.ok:
Expand Down
8 changes: 4 additions & 4 deletions poem/Poem/api/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def test_put_metric_superuser(self, func):
metric = poem_models.Metric.objects.get(name='argo.AMS-Check')
versions = poem_models.TenantHistory.objects.filter(
object_id=metric.id, content_type=self.ct
)
).order_by("-date_created")
self.assertEqual(versions.count(), 2)
serialized_data = json.loads(
versions[0].serialized_data
Expand Down Expand Up @@ -781,7 +781,7 @@ def test_put_metric_regular_user(self, func):
metric = poem_models.Metric.objects.get(name='argo.AMS-Check')
versions = poem_models.TenantHistory.objects.filter(
object_id=metric.id, content_type=self.ct
)
).order_by("-date_created")
self.assertEqual(versions.count(), 2)
serialized_data = json.loads(
versions[0].serialized_data
Expand Down Expand Up @@ -1622,7 +1622,7 @@ def test_put_passive_metric_superuser(self, func):
metric = poem_models.Metric.objects.get(name='org.apel.APEL-Pub')
versions = poem_models.TenantHistory.objects.filter(
object_id=metric.id, content_type=self.ct
)
).order_by("-date_created")
self.assertEqual(versions.count(), 2)
serialized_data = json.loads(
versions[0].serialized_data
Expand Down Expand Up @@ -1691,7 +1691,7 @@ def test_put_passive_metric_regular_user(self, func):
metric = poem_models.Metric.objects.get(name='org.apel.APEL-Pub')
versions = poem_models.TenantHistory.objects.filter(
object_id=metric.id, content_type=self.ct
)
).order_by("-date_created")
self.assertEqual(versions.count(), 2)
serialized_data = json.loads(
versions[0].serialized_data
Expand Down
42 changes: 21 additions & 21 deletions poem/Poem/api/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,6 @@ def test_sync_tags(self, mock_put):
"Accept": "application/json"
},
data=json.dumps([
{
"name": "test.AMS-Check",
"tags": [
"test_tag1",
"test_tag2"
]
},
{
"name": "argo.AMSPublisher-Check",
"tags": [
Expand All @@ -270,6 +263,13 @@ def test_sync_tags(self, mock_put):
"name": "org.apel.APEL-Pub",
"tags": []
},
{
"name": "test.AMS-Check",
"tags": [
"test_tag1",
"test_tag2"
]
},
{
"name": "test.EMPTY-metric",
"tags": []
Expand All @@ -294,13 +294,6 @@ def test_sync_tags_with_error(self, mock_put):
"Accept": "application/json"
},
data=json.dumps([
{
"name": "test.AMS-Check",
"tags": [
"test_tag1",
"test_tag2"
]
},
{
"name": "argo.AMSPublisher-Check",
"tags": [
Expand All @@ -318,6 +311,13 @@ def test_sync_tags_with_error(self, mock_put):
"name": "org.apel.APEL-Pub",
"tags": []
},
{
"name": "test.AMS-Check",
"tags": [
"test_tag1",
"test_tag2"
]
},
{
"name": "test.EMPTY-metric",
"tags": []
Expand Down Expand Up @@ -348,13 +348,6 @@ def test_sync_tags_with_error_without_msg(self, mock_put):
"Accept": "application/json"
},
data=json.dumps([
{
"name": "test.AMS-Check",
"tags": [
"test_tag1",
"test_tag2"
]
},
{
"name": "argo.AMSPublisher-Check",
"tags": [
Expand All @@ -372,6 +365,13 @@ def test_sync_tags_with_error_without_msg(self, mock_put):
"name": "org.apel.APEL-Pub",
"tags": []
},
{
"name": "test.AMS-Check",
"tags": [
"test_tag1",
"test_tag2"
]
},
{
"name": "test.EMPTY-metric",
"tags": []
Expand Down
30 changes: 11 additions & 19 deletions poem/Poem/frontend/react/AggregationProfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,16 @@ export const AggregationProfilesChange = (props) => {
const { data: webApiAP, error: errorWebApiAP, isLoading: loadingWebApiAP } = useQuery(
[`${publicView ? 'public_' : ''}aggregationprofile`, 'webapi', profile_name],
() => fetchAP(webapi, backendAP.apiid),
{ enabled: !!backendAP }
{
enabled: !!backendAP,
initialData: () => {
return queryClient.getQueryData(
[`${publicView ? "public_" : ""}aggregationprofile`, "webapi"]
)?.find(
profile => profile.id == backendAP.apiid
)
}
}
)

const { data: metricProfiles, error: errorMetricProfiles, isLoading: loadingMetricProfiles } = useQuery(
Expand Down Expand Up @@ -996,7 +1005,7 @@ export const AggregationProfilesChange = (props) => {
else if (errorMetricProfiles)
return (<ErrorComponent error={errorMetricProfiles} />)

else if (!loadingUserDetails && metricProfiles) {
else if ((addview || (backendAP && webApiAP) && metricProfiles)) {
if (!listServices && !publicView && !addview)
setListServices(!addview ? extractListOfServices(webApiAP.metric_profile, metricProfiles) : [])

Expand Down Expand Up @@ -1192,13 +1201,6 @@ export const AggregationProfilesList = (props) => {
const location = props.location;
const publicView = props.publicView

const webapi = new WebApi({
token: props.webapitoken,
metricProfiles: props.webapimetric,
aggregationProfiles: props.webapiaggregation
})
const queryClient = useQueryClient();

const { data: userDetails, error: errorUserDetails, isLoading: loadingUserDetails } = useQuery(
'userdetails', () => fetchUserDetails(true)
);
Expand All @@ -1221,16 +1223,6 @@ export const AggregationProfilesList = (props) => {
accessor: e =>
<Link
to={`/ui/${publicView ? 'public_' : ''}aggregationprofiles/` + e.name}
onMouseEnter={ async () => {
await queryClient.prefetchQuery(
[`${publicView ? 'public_' : ''}aggregationprofile`, 'webapi', e.name],
() => fetchAP(webapi, e.apiid)
);
await queryClient.prefetchQuery(
[`${publicView ? 'public_' : ''}metricprofile`, 'webapi'],
() => fetchMetricProfiles(webapi)
);
} }
>
{e.name}
</Link>,
Expand Down
22 changes: 17 additions & 5 deletions poem/Poem/frontend/react/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,15 @@ const TenantRouteSwitch = ({webApiAggregation, webApiMetric, webApiThresholds, w
/>}
/>
<Route exact path="/ui/probes/:name" render={props => <ProbeComponent {...props} isTenantSchema={true} />}/>
<Route exact path="/ui/metrics" render={props => <ListOfMetrics {...props} type='metrics' isTenantSchema={true} />} />
<Route exact path="/ui/metrics"
render={ props => <ListOfMetrics
{...props}
type='metrics'
isTenantSchema={true}
webapimetric={webApiMetric}
webapitoken={token}
/> }
/>
<Route exact path="/ui/metrics/:name/history" render={props => <HistoryComponent {...props} object='metric'/>}/>
<Route exact path="/ui/metrics/:name/history/compare/:id1/:id2" render={props => <CompareMetrics {...props} type='metric'/>}/>
<Route exact path="/ui/metrics/:name/history/:version" render={props => <MetricVersionDetails {...props}/>}/>
Expand Down Expand Up @@ -243,7 +251,6 @@ const TenantRouteSwitch = ({webApiAggregation, webApiMetric, webApiThresholds, w
{...props}
webapithresholds={webApiThresholds}
webapimetric={webApiMetric}
webapireports={webApiReports}
webapitoken={token}
/> }
/>
Expand Down Expand Up @@ -443,7 +450,6 @@ const TenantRouteSwitch = ({webApiAggregation, webApiMetric, webApiThresholds, w
{...props}
webapithresholds={webApiThresholds}
webapimetric={webApiMetric}
webapireports={webApiReports}
webapitoken={token}
/> }
/>
Expand Down Expand Up @@ -912,7 +918,14 @@ const App = () => {
<Route exact path="/ui/public_metrics"
render={props =>
<PublicPage privacyLink={privacyLink} termsLink={termsLink}>
<ListOfMetrics type='metrics' publicView={true} isTenantSchema={true} {...props}/>
<ListOfMetrics
type='metrics'
publicView={true}
isTenantSchema={true}
webapitoken={token}
webapimetric={webApiMetric}
{...props}
/>
</PublicPage>
}
/>
Expand Down Expand Up @@ -1015,7 +1028,6 @@ const App = () => {
publicView={true}
webapithresholds={webApiThresholds}
webapimetric={webApiMetric}
webapireports={webApiReports}
webapitoken={token}
/>
</PublicPage>
Expand Down
32 changes: 8 additions & 24 deletions poem/Poem/frontend/react/MetricProfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,20 @@ export const MetricProfilesComponent = (props) => {
{
enabled: (publicView || !addview),
initialData: () => {
return queryClient.getQueryData(`${publicView ? 'public_' : ''}metricprofile`)?.find(mpr => mpr.name === profile_name)
return queryClient.getQueryData([`${publicView ? 'public_' : ''}metricprofile`, "backend"])?.find(mpr => mpr.name === profile_name)
}
}
)

const { data: webApiMP, error: errorWebApiMP, isLoading: loadingWebApiMP } = useQuery(
[`${publicView ? 'public_' : ''}metricprofile`, 'webapi', profile_name],
() => fetchMetricProfile(webapi, backendMP.apiid),
{ enabled: !!backendMP }
{
enabled: !!backendMP,
initialData: () => {
return queryClient.getQueryData([`${publicView ? "public_" : ""}metricprofile`, "webapi"])?.find(profile => profile.id == backendMP.apiid)
}
}
)

const { data: metricsAll, error: errorMetricsAll, isLoading: loadingMetricsAll } = useQuery(
Expand Down Expand Up @@ -828,7 +833,7 @@ export const MetricProfilesComponent = (props) => {
else if (errorServiceFlavoursAll)
return (<ErrorComponent error={errorServiceFlavoursAll} />)

else if (!loadingUserDetails && !loadingBackendMP && !loadingWebApiMP && !loadingMetricsAll && !loadingServiceFlavoursAll)
else if (addview || (backendMP && webApiMP) && (publicView || (metricsAll && serviceFlavoursAll)))
{
let write_perm = undefined

Expand Down Expand Up @@ -1116,12 +1121,6 @@ export const MetricProfilesList = (props) => {
const location = props.location;
const publicView = props.publicView

const webapi = new WebApi({
token: props.webapitoken,
metricProfiles: props.webapimetric
})
const queryClient = useQueryClient();

const { data: userDetails, error: errorUserDetails, status: statusUserDetails } = useQuery(
'userdetails', () => fetchUserDetails(true)
);
Expand All @@ -1144,21 +1143,6 @@ export const MetricProfilesList = (props) => {
accessor: e =>
<Link
to={`/ui/${publicView ? 'public_' : ''}metricprofiles/` + e.name}
onMouseEnter={ async () => {
await queryClient.prefetchQuery(
[`${publicView ? 'public_' : ''}metricprofile`, 'webapi', e.name],
() => fetchMetricProfile(webapi, e.apiid)
);
if (!publicView) {
await queryClient.prefetchQuery(
'metricsall', () => fetchAllMetrics()
);

await queryClient.prefetchQuery(
'serviceflavoursall', () => fetchServiceFlavours()
);
}
} }
>
{e.name}
</Link>,
Expand Down
Loading

0 comments on commit cee7802

Please sign in to comment.