FreeSWITCH - Insert only 1 call leg CDR - freeswitch

I am trying to bridge two legs using uuid_bridge and everything is working OK except CDR.
It is inserting to DB table v_xml_cdr the details for the first UUID.
uuid_bridge uuid_leg_a uuid_leg_b.

Related

How to count number of DB table rows where column B value is "x" for the first occurrence of column A values in Laravel

I'm pretty new to Laravel. I have a projects table in MySQL DB represented by a model Project.php . I want to count rows based on two different column values. Each client can have multiple projects, and the status may be ongoing or completed. Let's say the client_id column (Column A) and the status column (Column B) are the two columns I want to base my counting upon.
I want to be able to count only the first row (if multiple exists) of the MySQL table where a particular client have column B value as ongoing as well as all other clients with column B values as ongoing. The image below depicts what the table looks like:
In this case, client_ids 1 and 3 have two ongoing projects each, I want to be able to count them as 1 each along with others (client_id 2). So the count for clients with ongoing projects should be 3.
I can count all rows with ongoing project with this code snippet
Project::where('status', 'Ongoing')->count();
But cannot differentiate if a client has more than 1 projects ongoing. Please kindly assist me with this.
If you want to count how many clients have at least one ongoing project you essentially have two options:
Group by:
$count = Project::where('status', 'Ongoing')
->select('client_id')
->groupBy('client_id')
->count();
Use an eloquent relationship
If you define a relationship between the Client and Project model you can get all clients with ongoing projects:
$count = Client::whereHas('project', function ($q) {
$q->where('status', 'Ongoing');
})->count();
The first method should be a bit faster but if you then want to retrieve the clients it's easier to adapt the 2nd method to return the clients instead of the count
Get the Client id for example
$client_id
Project::where('client_id', $clientId)->where('status', 'Ongoing')->count();

NiFi Lookup Service Error - Failed to Lookup Coordinates in Lookup Service

We keep getting this error when trying to use any Lookup Service (NiFi or 3rd party) to append additional attributes to our initial DB2 Query:
Failed to lookup coordinates {LEGAL_ENTITY_ID_NUM=13366} in Lookup Service
Has anyone had any success merging data from 2 different sql queries based on a common Unique ID from both queries? We've tried LookupRecord which uses Lookup Service, MergeRecord, and MergeContent - nothing seems to work??
Bottom line is - we have an initial main query (ID & Status) - then want to append an additional attribute (Name) from a 2nd query (just contains ID & Name) - onto each record of the main query - after joining on ID.
Whenever we try using LookupRecord, and pass the ID as a parameter via ? marks, we keep getting the above error. We've gotten nowhere with MergeRecord too. We have learned how to MergeContent, but that is not really what we want (is just a workaround).

Insert Update and delete source flag records in target using informatica

I implemented mapping same as below. can someone suggest that is the good approach or not.
old records copied from production so they didn't provide flag for those records. only new records we will get flag.
Source data:
col1 col2 col3 DML_FLAG
1 a 123 NULL(old record)
2 b 456 I
3 c 678 U
Mapping:
Source...>SQ...>exp...>lkp(on target to identify new or update)
..>exp..>...>RTR(for insert and update)-->upd(for update)...>target
First time load I have to load all records i.e full load(old records (DML_flag is null) and new records
From 2nd run I have to capture only changed records from source.For this I am using mapping variables
Here I have a question like, we have already I and U flags are available in source again I am using LKP,with out lookup, I can use DML_FLAG with two groups I and U in RTR.
But I need to refresh the data in every 30mints,with in 30 mints one record inserted(I) and same record got updated then flag changed to 'U' in the source, same record not available in the target, in that case can how can I capture that new record with flag 'U' without lkp.
can someone suggest how can I do this without lookup?
From what I understand of your question, you want to make sure you apply the insert in your target before you apply the update to that same record - is this correct? If so the just use a target load plan having inserts routed to separate alias of same target and higher up in the load order than updates
The answer to whether this is correct as a design choice depends on what the target db is... for a datawarehouse fact table you would usually insert all records be they inserts or updates because you would be reporting on the event rather than the record state. For a dimension table it would depend on your slow changing dimension strategy

how to create a new record dynamically using informatica powercenter

I have employee's leaves related data and payment related information.
e.g. Employee E1 has taken maternity leave this year. She needs to paid for 6 months and if she is on leave for greater duration (like 8 months) , I need to create two records for her.
One for the allowed duration and the other for extended duration.
Employee LeaveStartDAte LeaveEndDate Total_days_taken Total_days_allowed LeaveType
e1 1Jan2013 31Aug2013 242 186 ML
Target expected :
Employee LeaveStartDAte LeaveEndDate Leavetype
e1 1Jan2013 30June2013 ML
e1 1July 2013 31Aug2013 Extended ML
How can create the second record dynamically in informatica mapping?
Generally speaking, we use java transformation in informatica to dynamically create new rows. However, for scenarios like the one you described, where you only need to create one extra row based on some condition you can achieve this by adding two target instances and populating the second target instance conditionally (using a router or filter transformation).
You can do something like this:
Create two sets of ports for LeaveStartDate, LeaveEndDate and LeaveType in an expression, and calculate their values accordingly. For example:
LeaveStartDate1 -> source LeaveStartDate
LeaveStartDate2 -> LeaveStartDate + Total_days_allowed + 1
Now connect first set of ports directly to a target instance. Connect the second set of ports to another target instance through a filter. The filter condition would be something like Total_days_taken > Total_days_allowed. You can also do this using a router, if you like.
You can use two pipelines in a mapping - one to load the records for insert and the 2nd used to combined the insert with update.

WCF Data Services - neither .Expand or .LoadProperty seems to do what I need

I am building a school management app where they track student tardiness and absences. I've got three entities to help me in this. A Students entity (first name, last name, ID, etc.); a SystemAbsenceTypes entity with SystemAbsenceTypeID values for Late, Absent-with-Reason, Absent-without-Reason; and a cross-reference table called StudentAbsences (matching the student IDs with the absence-type ID, plus a date, and a Notes field).
What I want to do is query my entities for a given student, and then add up the number of each kind of Absence, for a given date range. I prepare my currentStudent object without a problem, then I do this...
Me.Data.LoadProperty(currentStudent, "StudentAbsences") 'Loads the cross-ref data
lblDaysLate.Text = (From ab In currentStudent.StudentAbsences Where ab.SystemAbsenceTypes.SystemAbsenceTypeID = Common.enuStudentAbsenceTypes.Late).Count.ToString
...and this second line fails, complaining "Object reference not set to an instance of an object."
I presume the problem is that while it DOES see that there are (let's say) four absences for the currentStudent (ie, currentStudent.StudentAbsences.Count = 4) -- it can't yet "peer into" each one of the absences to look at its type. In fact, each of the four StudentAbsence objects has a property called SystemAbsenceType, which then finally has the SystemAbsenceTypeID.
How do I use .Expand or .LoadProperty to make this happen? Do I need to blindly loop through all these collections, firing off .LoadProperty on everything before I can do my query?
Is there some other technique?
When you load the student, try expanding the related properties.
var currentStudent = context.Students.Expand("StudentAbsences")
.Expand("StudentAbsences/SystemAbsenceTypes")
.Where(....).First();

Resources