Laravel error on merge collection later to upgrate from 4.0 to 4.1 - collections

Later to upgrade Laravel version i found that the Collection::merge method isn't working well.
Not sure if it is my problem, i can't find an error. Lets see some information:
print_r($ecb->count());
print_r($boc->count());
// merge both
$cubes = $ecb->merge($boc);
print_r($cubes->count());
dd();
output:
36 27 1
the merge should to give like output 36 + 27 (there isn't duplicate element on the collection)
More debug information:
print_r($ecb->toArray());
print_r($boc->toArray());
// merge both
$cubes = $ecb->merge($boc);
print_r($cubes->toArray());
dd();
output (is a bit long): http://laravel.io/bin/PdVj1#7
Any idea?
Thanks

Yes - it appears to have changed between 4 and 4.1
See this Github issue: https://github.com/laravel/framework/issues/3445
In essence Eloquent collections, upon merging, remove models with duplicate primary keys.
I'm running Laravel 4.1.29 - and I get a different output to you with count() - but in essence it just removes duplicate ids.

I see that in Laravel 4.1 merge delete element with same ids ( https://github.com/laravel/framework/issues/3445 )
To have the same behavior i should to change the code like it:
$boc->each(function($cube) use ($ecb)
{
$ecb->push($cube);
});

The merge function uses Model#getKey() to differentiate different models - do the models you are using have a primary key specified properly? I notice they don't have the standard id field.

Related

Enterprise Custom field formula in MS Project server 2016

I am trying to implement a custom formula in Enterprise Custom field of MS Project.
Formula is as below:
``` ([Baseline Cost]*[DurationCustom])/[Baseline Duration]
`[Baseline Cost] and [Baseline Duration] are fields directly from MS Project,
[DurationCustom] is an enterprise custom field with Entity:task and Type:Number.` ```
For instance if
[Baseline Cost] = 1 ----- Type:Cost(₹1.00)
[DurationCustom] = 100 ----- Type:Number(100)
[Baseline Duration] = 100 ----Type:Number(100d)
Expected result: 1
Current result: 0.21
Can anyone suggest if the error is due to the data type.
Also, if there is a possibility to convert "100d" to simply a number "100".
P.S: I am using MS Project server 2016.
Thanks
I suggest you do the following. Break down your formula into three parts (separately) to see what value appears for each of the variables. For example, what do you get with the following:
Number1 = [Baseline Cost]
Then do the same for [DurationCustom] and [Baseline Duration]. That will tell you how Project "sees" the values and likely tell you why you get the result you do.
As far as converting "100d" to "100", yes it can be done but it isn't necessary. The "100d" is a display value based on your option setting. Internally, "100d" is stored as a number, in minutes, without any unit suffix.
John

How to combine many records value into one record

As you can see from the below picture I was able to combine two deals (blocked red) but the output should have one result instead of two. If anyone has any solutions on this please advise.
The red blocked component has more than one record, each record has an amount, the sum of all record amount must be shown in a single row.
record1: Amount:100
record2: Amount:200
record3: Amount:500
Merge of all records is following
record: Amount:800
Is it possible to merge many rows into a single row in integromat?
Based on your screenshot you aggregate an incorrect module. Source module in your aggregator has to be set to a module that generates multiple modules, in your case, it is module 10.
You aggregate module 14 that generates for every input module a single output module, there is nothing to aggregate. Module 10 returns for a single input 2 bundles.
Your case:
/---[6]---([14]---[11 aggregator])---
---[10] multiple output bundles
\---[6]---([14]---[11 aggregator])---
Solution:
/---[6]---[14]---\
---([10] [11 aggregator])--- single output bundle
\---[6]---[14]---/
Your scenario has to look like this (Aggregator: Source module = module no.10):

Creating graph in titan from data in csv - example wiki.Vote gives error

I am new to Titan - I loaded titan and successfully ran GraphOfTheGods example including queries given. Next I went on to try bulk loading csv file to create graph and followed steps in Powers of ten - Part 1 http://thinkaurelius.com/2014/05/29/powers-of-ten-part-i/
I am getting an error in loading wiki-Vote.txt
gremlin> g = TitanFactory.open("/tmp/1m") Backend shorthand unknown: /tmp/1m
I tried:
g = TitanFactory.open('conf/titan-berkeleydb-es.properties’)
but get an error in the next step in load-1m.groovy
==>titangraph[berkeleyje:/titan-0.5.4-hadoop2/conf/../db/berkeley] No signature of method: groovy.lang.MissingMethodException.makeKey() is applicable for argument types: () values: [] Possible solutions: every(), any()
Any hints what to do next? I am using groovy for the first time. what kind of groovy expertise needed for working with gremlin
That blog post is meant for Titan 0.4.x. The API shifted when Titan went to 0.5.x. The same principles discussed in the posts generally apply to data loading but the syntax is different in places. The intention is to update those posts in some form when Titan 1.0 comes out with full support of TinkerPop3. Until then, you will need to convert those code examples to the revised API.
For example, an easy way to create a berkeleydb database is with:
g = TitanFactory.build()
.set("storage.backend", "berkeleyje")
.set("storage.directory", "/tmp/1m")
.open();
Please see the docs here. Then most of the schema creation code (which is the biggest change) is now described here and here.
After much experimenting today, I finally figured it out. A lot of changes were needed:
Use makePropertyKey() instead of makeKey(), and makeEdgeLabel() instead of makeLabel()
Use cardinality(Cardinality.SINGLE) instead of unique()
Building the index is quite a bit more complicated. Use the management system instead of the graph both to make the keys and labels, as well as build the index (see https://groups.google.com/forum/#!topic/aureliusgraphs/lGA3Ye4RI5E)
For posterity, here's the modified script that should work (as of 0.5.4):
g = TitanFactory.build().set("storage.backend", "berkeleyje").set("storage.directory", "/tmp/1m").open()
m = g.getManagementSystem()
k = m.makePropertyKey('userId').dataType(String.class).cardinality(Cardinality.SINGLE).make()
m.buildIndex('byId', Vertex.class).addKey(k).buildCompositeIndex()
m.makeEdgeLabel('votesFor').make()
m.commit()
getOrCreate = { id ->
def p = g.V('userId', id)
if (p.hasNext()) {
p.next()
} else {
g.addVertex([userId:id])
}
}
new File('wiki-Vote.txt').eachLine {
if (!it.startsWith("#")){
(fromVertex, toVertex) = it.split('\t').collect(getOrCreate)
fromVertex.addEdge('votesFor', toVertex)
}
}
g.commit()

Cucumber: In which order the feature tags are followed in a cucumber script?

I am facing an issue where I need to run script with three features. Let's say we have 3 feature files with tag names as #smoke1, #smoke2 and #smoke3. And I want these to be executed in that sequence.
Issue is that smoke3 is executing first and rest of them afterwards.
This is my script:
#Cucumber.Options(
glue = { "com.abc", "cucumber.runtime.java.spring.hooks" },
features = "classpath:",
format = { "json", "json:target/cucumber.json" },
tags = "#smoke1, #smoke2, #smoke3"
)
public class ex_Test extends AbstractTest { }
Warning: This only works in older versions of Cucumber.
Cucumber feature files are executed in alphabetical order by path and filename. The execution order is not based on tags.
However, if you specifically specify features, they should be run in the order declared.
For example:
#Cucumber.Options(features={"first_smoke.feature", "another_smoke.feature"})
Should run first_smoke and then another_smoke (compared to the default which is to run in the other order.
Ok we got it , We can have multiple tags for a single scenario like this #tag1 #tag2 #tag3.
You can not define the order in way below.
#Cucumber.Options(features={"first_smoke.feature", "another_smoke.feature"})
Cucumber determines the only alphabetical order and even only first letter of the word.
You can have how many tags you want in feature file, if you want to trigger feature file more times, it's not working like you will add tag more time or more tags from feature like:
tags = {"#Reports,#Reports"}
And tests are triggered in alphabetical order, it's checking tags not feature file name.

Why does Qt add more than three columns when I use restoreState() on a QTableWidget?

My code looks somehow like the following:
table = QTableWidget()
table.horizontalHeader().restoreState(settings.value("savedState"))
table.setColumnCount(3)
settings.setValue("savedState", table.horizontalHeader().saveState())
If I run it the first time it there are only 3 column headers. The second time there are 6 and the third 9... The strange thing is table.columnCount() is always 3. If i remove table.setColumnCount(3) there are no columns at all.
Why is this happening and is it a bug or intentional?
UPDATE
Adding table.clearContents() before table.setColumnCount(3) made it work. I still think it's a bug.
Which platform and what Qt version is this? http://chaos.troll.no/~hhartz/tablecolumns.tar seems to work fine using latest Qt 4.5
What happens with?
table = QTableWidget();
table.setColumnCount(3);
table.horizontalHeader().restoreState(settings.value("savedState"));

Resources