-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into staging
- Loading branch information
Showing
64 changed files
with
2,122 additions
and
536 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Bloxberg.org certification | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- development | ||
- staging | ||
- production | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
certify-code: | ||
name: Certify code on bloxberg.org | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Bloxberg certifier | ||
id: bloxberg-certifier | ||
uses: bloxberg-org/[email protected] | ||
with: | ||
authorName: Max Planck Digital Library | ||
researchTitle: ${{github.repository}} ${{github.ref_type}} ${{github.ref}} ${{github.sha}} | ||
|
||
- name: Print certification | ||
id: output | ||
run: echo -e "\nYour git branch has been successfully certified by bloxberg. To verify it you can copy paste the following into a json file and verify it on certify.bloxberg.org:\n\n##########\n" && echo "${{ steps.bloxberg-certifier.outputs.certificateVerification }}" && echo -e "\n##########" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package geo | ||
|
||
import ( | ||
"api/utils/file_download" | ||
"api/utils/log" | ||
"api/utils/observer" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"strings" | ||
"time" | ||
) | ||
|
||
type Controller struct { | ||
config Config | ||
ticker *time.Ticker | ||
done chan bool | ||
} | ||
|
||
func (idc *Controller) Init(config Config) { | ||
idc.config = config | ||
} | ||
|
||
func (idc *Controller) Load(geoInformationType string) (geoInformationMap map[string]Location, e error) { | ||
var sourceUrl = "" | ||
if geoInformationType == "bloxberg-validators" { | ||
sourceUrl = idc.config.BloxbergValidatorsSourceUrl | ||
} else { | ||
sourceUrl = idc.config.MpgInstitutesSourceUrl | ||
} | ||
jsonString, err := file_download.GetJsonStringFromFile(sourceUrl, map[string]string{"hatnote-gis-api-password": idc.config.ApiPassword}) | ||
if err != nil { | ||
log.Error("Error while loading geo information data.", err, log.Geo) | ||
e = errors.New("could not load geo information data") | ||
return | ||
} | ||
|
||
geoInformationMap = make(map[string]Location) | ||
var geoInformation []Information | ||
err = json.Unmarshal([]byte(jsonString), &geoInformation) | ||
if err != nil { | ||
return geoInformationMap, errors.New(fmt.Sprint("Failed to unmarshal json from geoInformation json: ", sourceUrl, "error: ", err)) | ||
} | ||
|
||
log.Info(Top3ToString(geoInformation), log.Geo) | ||
|
||
// generate map from array and use this in bloxberg service | ||
for _, geoItem := range geoInformation { | ||
geoInformationMap[strings.ToLower(geoItem.Id)] = Location{ | ||
Coordinate: geoItem.Coordinate, | ||
CountryId: geoItem.CountryId, | ||
StateId: geoItem.StateId, | ||
} | ||
} | ||
|
||
if log.LogLevel >= 5 { | ||
log.Debug(fmt.Sprintf("geo information map:"), log.Geo) | ||
for k, v := range geoInformationMap { | ||
log.Debug(fmt.Sprintf("id: %s, lat,long: %f,%f", k, v.Coordinate.Lat, v.Coordinate.Long), log.Geo) | ||
} | ||
} | ||
|
||
return | ||
} | ||
|
||
func (idc *Controller) StartPeriodicSync(updatableControllers ...observer.UpdatableGeoInformation) *chan bool { | ||
if idc.config.PeriodicSync <= 0 { | ||
log.Warn("Periodic geo information data sync disabled.", log.Geo) | ||
return nil | ||
} | ||
oneDayInHours := 24 | ||
idc.ticker = time.NewTicker(time.Duration(idc.config.PeriodicSync*oneDayInHours) * time.Hour) | ||
idc.done = make(chan bool) | ||
|
||
go func() { | ||
for { | ||
select { | ||
case <-idc.done: | ||
return | ||
case <-idc.ticker.C: | ||
log.Info("Syncing geo information data ...", log.Geo) | ||
for _, controller := range updatableControllers { | ||
controller.UpdateGeoInformation() | ||
} | ||
} | ||
} | ||
}() | ||
|
||
return &idc.done | ||
} | ||
|
||
func (idc *Controller) StopPeriodicSync() { | ||
if idc.ticker != nil { | ||
log.Info("Stopping periodic geo information data sync.", log.Geo) | ||
idc.ticker.Stop() | ||
} | ||
if idc.done != nil { | ||
idc.done <- true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package geo | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type Config struct { | ||
BloxbergValidatorsSourceUrl string `yaml:"bloxbergValidatorsSourceUrl"` // can be a http resource or a local file | ||
MpgInstitutesSourceUrl string `yaml:"mpgInstitutesSourceUrl"` // can be a http resource or a local file | ||
PeriodicSync int `yaml:"periodicSync"` // days | ||
ApiPassword string `yaml:"apiPassword"` | ||
} | ||
|
||
type Information struct { | ||
Name string `json:"name"` | ||
Id string `json:"id"` | ||
Coordinate Coordinate `json:"coordinate"` | ||
CountryId string `json:"countryId"` | ||
StateId string `json:"stateId"` | ||
} | ||
|
||
type Location struct { | ||
Coordinate Coordinate `json:"coordinate"` | ||
CountryId string `json:"countryId"` | ||
StateId string `json:"stateId"` | ||
} | ||
|
||
type Coordinate struct { | ||
Lat float64 `json:"lat"` | ||
Long float64 `json:"long"` | ||
} | ||
|
||
func Top3ToString(information []Information) string { | ||
var sb strings.Builder | ||
counter := 0 | ||
sb.WriteString("\n") | ||
sb.WriteString("Top 3 geo information data:\n\n") | ||
for _, informationItem := range information { | ||
sb.WriteString(fmt.Sprintln(" Name: ", informationItem.Name)) | ||
sb.WriteString(fmt.Sprintln(" Id: ", informationItem.Id)) | ||
sb.WriteString(fmt.Sprintln(" CountryId: ", informationItem.CountryId)) | ||
sb.WriteString(fmt.Sprintln(" StateId: ", informationItem.StateId)) | ||
sb.WriteString(fmt.Sprintln(" Coordinate: ")) | ||
sb.WriteString(fmt.Sprintln(" Latitude: ", informationItem.Coordinate.Lat)) | ||
sb.WriteString(fmt.Sprintln(" Longitude: ", informationItem.Coordinate.Long)) | ||
sb.WriteString(" ----------\n") | ||
counter++ | ||
if counter == 3 { | ||
break | ||
} | ||
} | ||
return sb.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIIfDCCBmSgAwIBAgIQOUu5ZIa5j0cbP+e0nkgtajANBgkqhkiG9w0BAQwFADBE | ||
MQswCQYDVQQGEwJOTDEZMBcGA1UEChMQR0VBTlQgVmVyZW5pZ2luZzEaMBgGA1UE | ||
AxMRR0VBTlQgT1YgUlNBIENBIDQwHhcNMjMxMTI0MDAwMDAwWhcNMjQxMTIzMjM1 | ||
OTU5WjCBhTELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJheWVybjFHMEUGA1UECgw+ | ||
TWF4LVBsY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78y8Q0y0XbUJAVKLMcWEu6alQdqYR7jZv | ||
Elk2aOhdiS+ckRXGubrts/V2g3Om79D7AtmiEYqA3z8HoBgZ1b47GTnTzUM6ad+G | ||
cYQ8FlIsCNfn00r6hdXLyzoItyOchuWu6QZwTD1FXLNbVExSn4PNanlyWd6L4eVC | ||
WhU/sDSvCX3kkYsAki1TzmTt08le5dOH/H/IZ7hDg9cw/OLOHIpPuB7RPZC0rx3x | ||
okCti+/Ecprc5ImxFMun86+33NguHUdu0S3EY8AJLmNCqC7V8kxXyCLByJc1RzZ3 | ||
RH9nik5/FzqqBNPAzOpGzJy8AkJyf7tlaGzib4Z9Y6Lj9uAhnWIXGls6tIqVb/jX | ||
Q2TPXamQTFeMO11Nc1k1YT1K4O1EaoX/ZIPUiWEl6mPVcjddg/18DtjPOmxwMpbm | ||
EFhhSdSXffcJ+3RL59Wqv79DWRuI6rHBVhJ30oW02hY+hqal2MbdzqFg7DhNugSH | ||
RcuDhsnkifz8+awNElS3bpaT4hJYMsw8acySaP3V+5FnDuh/DBeylYz6Vl2oPTHa | ||
i2koXKcWBL5fuJsmBMB//iTqsKzYfAjUUBBXo7e9T6LU70O7nmlaygsfxjBps8lJ | ||
nhVX1X3oyxGCK54sZp0huw== | ||
-----END CERTIFICATE----- |
Oops, something went wrong.