Do you know how I can change this:
{
"ax-lb-mtls-01" = {
"ax-lb-mtls-01/forwarding-subnet-01" = "10.100.0.203"
"ax-lb-mtls-01/forwarding-subnet-02" = "10.100.0.205"
}
"ax-lb-mtls-02" = {
"ax-lb-mtls-02/forwarding-subnet-01" = "10.100.0.204"
"ax-lb-mtls-02/forwarding-subnet-02" = "10.100.0.206"
}
}
into this:
{
"ax-lb-mtls-01/forwarding-subnet-01" = "10.100.0.203"
"ax-lb-mtls-01/forwarding-subnet-02" = "10.100.0.205"
"ax-lb-mtls-02/forwarding-subnet-01" = "10.100.0.204"
"ax-lb-mtls-02/forwarding-subnet-02" = "10.100.0.206"
}
I would like to transform this to use by another module.
You can do this as follows:
merge(values(local.input)...)
Related
I've been trying to create an export to excel file api in a production project.
But this api is working only for fewer data.
But when exporting for five thousand data, the excel file is downloaded after a long time with broken data in excel file.
Here is the code:
The route file-
Route::group(['prefix' => 'v1/export'], function () {
Route::get('/applied-candidate/{job_id}', 'Job\JobPostingUserController#exportAppliedCandidate');
});
In controller-
public function exportAppliedCandidate($jobposting_id)
{
$fileName = 'candidate_list_' . Carbon::now()->toDateString();
$exportable = new ExportableFromCollection(JobPostingUser::exportCandiateList($jobposting_id), JobPostingUser::listHeader());
return Excel::download($exportable, $fileName . '.xlsx');
}
In model-
public static function exportCandiateList($job_id): array {
$candidateList = JobPostingUser::where('posting_id', $job_id)
->join('users', 'users.id', '=' ,'job_posting_user.user_id')
->join('profile_basics', 'profile_basics.user_id', '=' ,'job_posting_user.user_id')
->join('job_postings', 'job_postings.id', '=' , 'job_posting_user.posting_id')
->select('job_postings.title as job_name',
'users.id as candidate_id',
'users.first_name',
'users.last_name',
'profile_basics.date_of_birth',
'profile_basics.gender',
'profile_basics.phone_personal',
'users.email',
'profile_basics.total_experience')->get()->toArray();
$final_result = [];
foreach($candidateList as $candidate) {
$bachelor = ProfileEducation::getBachelorInfo($candidate['candidate_id']);
$msc = ProfileEducation::getMasterInfo($candidate['candidate_id']);
$candidateInfo = [];
$job_name = JobPosting::where('id', $job_id)->first();
$job_name = $job_name ? $job_name->title: $job_id;
$candidateInfo['job'] = $job_name;
$candidateInfo['candidate_id'] = $candidate['candidate_id'];
$candidateInfo['name'] = $candidate['first_name'].' '.$candidate['last_name'];
$candidateInfo['date_of_birth'] = date('Y-m-d', strtotime($candidate['date_of_birth']));
$candidateInfo['gender'] = $candidate['gender'];
$candidateInfo['phone_personal'] = $candidate['phone_personal'];
$candidateInfo['email'] = $candidate['email'];
if($bachelor) {
$candidateInfo['b_university'] = empty($bachelor['institution']) ? $bachelor['other_institution'] : $bachelor['institution']['name'];
$candidateInfo['b_field'] = $bachelor['field'] ? ProfileService::getBachelorDegreeName($bachelor['field']): 'N/A';
$candidateInfo['b_major'] = $bachelor['major'] ? $bachelor['major']: 'N/A';
$candidateInfo['b_grade'] = $bachelor['grade'] ? $bachelor['grade']: 'N/A';
} else {
$candidateInfo['b_university'] = 'N/A';
$candidateInfo['b_field'] = '';
$candidateInfo['b_major'] = '';
$candidateInfo['b_grade'] = '';
}
if($msc) {
$candidateInfo['m_university'] = empty($msc['institution']) ? $msc['other_institution'] : $msc['institution']['name'];
$candidateInfo['m_field'] = $msc['field'] ? ProfileService::getMastersDegreeName($msc['field']): 'N/A';
$candidateInfo['m_major'] = $msc['major'] ? $msc['major']: 'N/A';
$candidateInfo['m_grade'] = $msc['grade'] ? $msc['grade']: 'N/A';
} else {
$candidateInfo['m_university'] = 'N/A';
$candidateInfo['m_field'] = '';
$candidateInfo['m_major'] = '';
$candidateInfo['m_grade'] = '';
}
$expericnece = self::getExperience($candidate['candidate_id']);
if($expericnece) {
$candidateInfo['company_name'] = $expericnece['company_name'];
$candidateInfo['started_in'] = $expericnece['started_in'];
$candidateInfo['ended_in'] = $expericnece['ended_in'];
$candidateInfo['responsibilitie'] = $expericnece['job_responsibilities'];
} else {
$candidateInfo['company_name'] = '';
$candidateInfo['started_in'] = '';
$candidateInfo['ended_in'] = '';
$candidateInfo['responsibilitie'] = '';
}
$candidateInfo['total_experience'] = $candidate['total_experience'];
$final_result[] = $candidateInfo;
}
return $final_result;
}
After exporting just few numbers are showing some columns in excel file. But file is correctly exported for lesser data(500 items).
Please suggest how I can change/optimise this query to work for any number of data?
Given the following list of objects where order is not guaranteed. How do I use terraform to sort a list and grab the latest value?
locals {
list_of_objects = [
{
name = "0.25388.50855"
sort_versions_by_semver = false
tags = {
"baseosimg" = "windows2022datacenter"
}
},
{
name = "0.25424.21095"
sort_versions_by_semver = false
tags = {
"baseosimg" = "windows2022datacenter"
}
},
{
name = "0.25399.6325"
sort_versions_by_semver = false
tags = {
"baseosimg" = "windows2022datacenter"
}
},
]
}
In terraform if you convert the list of objects to a map, it will automatically sort it. From there you can grab the last value (or first).
locals {
map_of_sorted_objects = { for a in local.list_of_objects : a.name => a }
}
output "test" {
value = lookup(
local.map_of_sorted_objects,
element(
sort(keys(local.map_of_sorted_objects)),
length(local.map_of_sorted_objects) - 1
)
)
}
Output
test = {
"name" = "0.25424.21095"
"sort_versions_by_semver" = false
"tags" = {
"baseosimg" = "windows2022datacenter"
}
}
I am struggling to take the output from a Terraform function (a list block) and convert it into a list of maps, I am trying to convert
The following:
mylist = [
{
key = "mykey1"
property1 = "mykey1property1"
property2 = "mykey1property2"
},
{
key = "mykey2"
property1 = "mykey2property1"
property2 = "mykey2property2"
}
]
into:
mylistmap = {
mykey1 = {
property1 = "mykey1property1"
property2 = "mykey1property2"
}
mykey2 = {
property1 = "mykey2property1"
property2 = "mykey2property2"
}
}
I think zipmap is what I need but I cant find any decent examples to do this.
Not sure if this is the best way possible, but with some manipulation with keys and values I was able to achieve what you want:
locals {
mylist = [
{
key = "mykey1"
property1 = "mykey1property1"
property2 = "mykey1property2"
},
{
key = "mykey2"
property1 = "mykey2property1"
property2 = "mykey2property2"
}
]
mylistmap = { for i in local.mylist: i.key => {
for k,v in i: k => v if k != "key"
}
}
}
Using terraform console, this yields the following values:
> local.mylistmap
{
"mykey1" = {
"property1" = "mykey1property1"
"property2" = "mykey1property2"
}
"mykey2" = {
"property1" = "mykey2property1"
"property2" = "mykey2property2"
}
}
I am attempting to install the Bloomberg API. I have followed all instructions and can run code without producing any errors. However it doesn't produce any useful output which makes me think something went wrong with the install. I've been trying this for four days and am banging my head against my keyboard! Hopefully someone has encountered this and can clue me in.
I'm using "IntradayTickExample" which is available here:
https://github.com/msitt/blpapi-python/blob/master/examples/IntradayTickExample.py
The output looks like this:
IntradayTickExample
Connecting to localhost:8194
12OCT2018_16:37:35.207 7780:22292 WARN blpapi_platformcontroller.cpp:347
blpapi.session.platformcontroller.{1} Connectivity restored.
Sending Request: IntradayTickRequest = {
security = "IBM US Equity"
eventTypes[] = {
TRADE
}
startDateTime = 2008-08-11T15:30:00.000
endDateTime = 2008-08-11T15:35:00.000
}
Processing Response
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
}
}
}
TIME TYPE VALUE SIZE CC
---- ---- ----- ---- --
------------------
(program exited with code: 0)
Any ideas?
Bloomberg limits the amount of tick history you can download to the most 10 recent days. Running a similar example to what you linked to will return data provided this is in the correct range (ran as of 2018-10-24).
import blpapi
HOST = "localhost"
PORT = 8194
def main():
sessionOptions = blpapi.SessionOptions()
sessionOptions.setServerHost(HOST)
sessionOptions.setServerPort(PORT)
session = blpapi.Session(sessionOptions)
if not session.start():
print("Failed to start session.")
return
session.openService("//blp/refdata")
refDataService = session.getService("//blp/refdata")
request1 = refDataService.createRequest("IntradayTickRequest")
request1.set("security", "IBM US Equity")
request1.getElement("eventTypes").appendValue("TRADE")
request1.set("startDateTime", "2008-08-11T15:30:00.000")
request1.set("endDateTime", "2008-08-11T15:35:00.000")
request2 = refDataService.createRequest("IntradayTickRequest")
request2.set("security", "IBM US Equity")
request2.getElement("eventTypes").appendValue("TRADE")
request2.set("startDateTime", "2018-10-23T15:30:00.000")
request2.set("endDateTime", "2018-10-23T15:30:01.000")
session.sendRequest(request1)
session.sendRequest(request2)
while True:
ev = session.nextEvent(500)
if ev.eventType() == blpapi.Event.TIMEOUT:
break
for msg in ev:
print(msg)
Running this you can see that data is obtained in the second example, since the date range is set appropriately.
main()
SessionConnectionUp = {
server = "localhost:8194"
}
SessionStarted = {
initialEndpoints[] = {
initialEndpoints = {
address = "localhost:8194"
}
}
}
ServiceOpened = {
serviceName = "//blp/refdata"
}
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
}
}
}
IntradayTickResponse = {
tickData = {
eidData[] = {
}
tickData[] = {
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.510000
size = 300
}
tickData = {
time = 2018-10-23T15:30:00.000+00:00
type = TRADE
value = 129.525000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 100
}
tickData = {
time = 2018-10-23T15:30:01.000+00:00
type = TRADE
value = 129.510000
size = 200
}
}
}
}
I've tried this:
variable "records" {
type = "map"
default = {
"mediapop.co." = ["www.mediapop.co"],
"mediapopinc.com." = ["mediapopinc.com", "www.mediapopinc.com"] ,
"mediapop.sg." = ["mediapop.sg", "www.mediapop.sg"],
}
}
output "records" {
value = "${flatten(values(var.records))}"
}
but values() only allows for flat maps. Is there a workaround?
Using transpose:
output "transpose" {
value = "${transpose(var.records))"
}
output "values" {
value = "${keys(transpose(var.records)))"
}
outputs
transpose = {
mediapop.sg = [mediapop.sg.]
mediapopinc.com = [mediapopinc.com.]
www.mediapop.co = [mediapop.co.]
www.mediapop.sg = [mediapop.sg.]
www.mediapopinc.com = [mediapopinc.com.]
}
values = [
mediapop.sg,
mediapopinc.com,
www.mediapop.co,
www.mediapop.sg,
www.mediapopinc.com
]