Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
compendium-v2
Commits
55c9346c
Commit
55c9346c
authored
7 months ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
use generics instead of any
convert URLs to https:// instead of unsecure http://
parent
8b0a6bc4
No related branches found
No related tags found
1 merge request
!134
Refactor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compendium-frontend/src/helpers/dataconversion.tsx
+7
-7
7 additions, 7 deletions
compendium-frontend/src/helpers/dataconversion.tsx
with
7 additions
and
7 deletions
compendium-frontend/src/helpers/dataconversion.tsx
+
7
−
7
View file @
55c9346c
...
@@ -664,15 +664,15 @@ export function createNetworkDarkFibreDataLookUp<Datatype extends NrenAndYearDat
...
@@ -664,15 +664,15 @@ export function createNetworkDarkFibreDataLookUp<Datatype extends NrenAndYearDat
};
};
}
}
export function getLatestData(data:
any
[])
{
export function getLatestData
<
T
extends
NrenAndYearDatapoint
>
(data:
T
[])
{
// Get the latest year for each NREN, and return the data for that year
// Get the latest year for each NREN, and return the data for that year
// Mainly used for URL data, which doesn't make sense to compare across years
// Mainly used for URL data, which doesn't make sense to compare across years
const
latestData
=
new
Map
<
string
,
any
>
();
const
latestData
=
new
Map
();
data
.
forEach
(
institution
=>
{
data
.
forEach
(
datapoint
=>
{
const
existingData
=
latestData
.
get
(
institution
.
nren
);
const
existingData
=
latestData
.
get
(
datapoint
.
nren
);
if
(
!
existingData
||
existingData
.
year
<
institution
.
year
)
{
if
(
!
existingData
||
existingData
.
year
<
datapoint
.
year
)
{
latestData
.
set
(
institution
.
nren
,
institution
);
latestData
.
set
(
datapoint
.
nren
,
datapoint
);
}
}
});
});
return
Array
.
from
(
latestData
.
values
());
return
Array
.
from
(
latestData
.
values
());
...
@@ -681,7 +681,7 @@ export function getLatestData(data: any[]) {
...
@@ -681,7 +681,7 @@ export function getLatestData(data: any[]) {
export function addHttpIfMissing(url: string)
{
export function addHttpIfMissing(url: string)
{
// check if it has a protocol, if not add http (href becomes relative to the current page, so we need to add the protocol to make it work properly)
// check if it has a protocol, if not add http (href becomes relative to the current page, so we need to add the protocol to make it work properly)
if
(
!
url
.
match
(
/^
[
a-zA-Z
]
+:
\/\/
/
))
{
if
(
!
url
.
match
(
/^
[
a-zA-Z
]
+:
\/\/
/
))
{
return
'
http://
'
+
url
;
return
'
http
s
://
'
+
url
;
}
}
return
url
;
return
url
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment