Hello!
I am trying to get how many people request translations. To do that, I am joinning tmgmt_job, tmgmt_job_item, users and node directly from database and I get this data example with this query:
Query
SELECT
u.`name`
-- tj.tjid
-- ,
-- , tj.source_language, tj.target_language
-- , tj. created, tj.label, tj.uid
, tji.`plugin`, tji.item_type, tji.item_id
, n.type
-- , n.title
, COUNT(tj.uid) as peticiones
FROM tmgmt_job tj
INNER JOIN users u ON u.uid = tj.uid
INNER JOIN tmgmt_job_item tji ON tji.tjid = tj.tjid AND tji.`plugin` = 'entity' AND tji.item_type = 'node'
INNER JOIN node n ON n.nid = tji.item_id
WHERE n.type IN ('oferta_b2c', 'evento_b2c', 'oferta_b2b', 'evento_b2b')
GROUP BY u.uid, n.type
ORDER BY peticiones DESC
;
Result
43asa099 entity node 228 oferta_b2c 4
43e09900 entity node 239 oferta_b2b 3
plaadsno entity node 752 oferta_b2c 1
ddfo_oro entity node 2888 oferta_b2b 1
When I tried to build a view to view this kind of info, a part of query was:
SELECT tmgmt_job_item.tjiid AS tjiid, users_node.name AS users_node_name, users_node.uid AS users_node_uid, node_tmgmt_job_item.type AS node_tmgmt_job_item_type
FROM
{tmgmt_job_item} tmgmt_job_item
INNER JOIN {node} node_tmgmt_job_item ON tmgmt_job_item.item_id = node_tmgmt_job_item.vid AND (tmgmt_job_item.item_type = 'node' AND tmgmt_job_item.plugin = 'node')
LEFT JOIN {tmgmt_job} tmgmt_job_tmgmt_job_item ON tmgmt_job_item.tjid = tmgmt_job_tmgmt_job_item.tjid
LEFT JOIN {users} users_node ON node_tmgmt_job_item.uid = users_node.uid
LIMIT 10 OFFSET 0
As you can see in bold, one condition get by Relation is " tmgmt_job_item.plugin = 'node'" and I think that is wrong, because I get "entity" in the column "plugin" when I retrieve data from the database.
This error came from here, line 35 inside: sources/node/views/tmgmt_node.views.inc as I show here:
'relationship' => array(
...
array(
'table' => 'tmgmt_job_item',
'field' => 'plugin',
'operator' => '=',
'value' => 'node',
),
),
),
If I change this line from node to entity, the result is correctly, but I am not sure If it is the correct approach.
Comment | File | Size | Author |
---|---|---|---|
#9 | tmgmt-plugin-set-incorrectly-in-node-source-relationship-2604132-9.patch | 969 bytes | vtkachenko |
#8 | tmgmt_node-views-reference-incorrect-2604132.patch | 1.01 KB | vtkachenko |
#2 | change_value-2604132-10504822.patch | 526 bytes | daniroyo |
interdiff.diff | 614 bytes | daniroyo | |
Comments
Comment #2
daniroyo CreditAttribution: daniroyo commentedI tried to created my first patch, but I am not sure the correct way.
Comment #3
daniroyo CreditAttribution: daniroyo commentedI am investigating a bit more about that.
There are a lot of piece of code that use entity as plugin, for example:
C:\devdesktop\esMadridPro\profiles\clusters\modules\contrib\tmgmt\sources\entity\ui\tmgmt_entity_ui.pages.inc
or...
C:\devdesktop\esMadridPro\profiles\clusters\modules\contrib\tmgmt\sources\entity\ui\tmgmt_entity_ui.ui.inc:145
Til the bug was resolve, I will use this piece of code to work properly.
Comment #4
BerdirThere are two different plugins. node and entity. node is the core translation.module, entity is entity_translation.
We only have views integration for the node source, while you seem to be using entity translation.
This is by design, we can't change this.
Comment #5
daniroyo CreditAttribution: daniroyo commentedThanks @Berdir for your response, You are right, we are using entity_translation, so, I assume It is ok by your point of view.
Comment #6
vtkachenko CreditAttribution: vtkachenko commentedWe have to use nid instead of vid in TMGMTNodeSourceViewsController::views_data().
Because $job_item->item_id stores nid, but not vid. That is why there difference in result.
Comment #7
vtkachenko CreditAttribution: vtkachenko commentedComment #8
vtkachenko CreditAttribution: vtkachenko commentedComment #9
vtkachenko CreditAttribution: vtkachenko commented