Template:Resultlink: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(mean query made quicker (70 ms with testvariable vs 450 ms with old))
(also sample and upload list queries updated)
Line 2: Line 2:


{{#sql-query:
{{#sql-query:
SELECT Var.Ident, Var.Name, Var.Unit, Run.Ident, Objinfo.Moment, Objinfo.Who, Run.Name as Method  
SELECT Var.Ident, Var.Name, Var.Unit, Run.Ident, Objinfo.Moment, Objinfo.Who, Run.Name as Method
FROM Obj as Var, Obj as Run, Cell, Objinfo
FROM Obj
WHERE Var.Ident = "Op_en{{PAGEID}}"
JOIN Cell ON Var.id = Cell.Obj_id_v
AND Var.id = Cell.Obj_id_v  
JOIN Obj AS Run ON Run.id = Cell.Obj_id_r
AND Run.id = Cell.Obj_id_r  
JOIN Objinfo ON Run.id = Objinfo.Obj_id
AND Run.id = Objinfo.Obj_id  
WHERE Var.Ident = "Op_en{{PAGEID}}"
GROUP BY Var.id, Run.id
GROUP BY Var.id, Run.id
ORDER BY Run.id DESC
ORDER BY Run.id DESC
Line 14: Line 14:
{{#sql-query:
{{#sql-query:
SELECT Cell.Obj_id_v AS Object, Cell_id AS Cell, Cell.Obj_id_r AS Upload, Obj.Ident, Obj.Name, N, GROUP_CONCAT(Loc.Location SEPARATOR ', ') AS Location, Obj.Unit, Mean, SD
SELECT Cell.Obj_id_v AS Object, Cell_id AS Cell, Cell.Obj_id_r AS Upload, Obj.Ident, Obj.Name, N, GROUP_CONCAT(Loc.Location SEPARATOR ', ') AS Location, Obj.Unit, Mean, SD
FROM (SELECT Obj_id_v, Obj_id_r FROM Obj JOIN Cell ON Obj.id=Cell.Obj_id_v WHERE Obj.Ident="Op_en{{PAGEID}}" GROUP BY Obj_id_r DESC LIMIT 0,1) AS Newest, Obj
FROM (SELECT Obj_id_v, Obj_id_r FROM Obj JOIN Cell ON Obj.id=Cell.Obj_id_v WHERE Obj.Ident="Op_en{{PAGEID}}" ORDER BY Obj_id_r DESC LIMIT 0,1) AS Newest, Obj
JOIN Cell ON Obj.id=Cell.Obj_id_v  
JOIN Cell ON Obj.id=Cell.Obj_id_v  
JOIN Loccell ON Cell.id=Loccell.Cell_id  
JOIN Loccell ON Cell.id=Loccell.Cell_id  
Line 26: Line 26:
{{#sql-query:
{{#sql-query:
SELECT Temp.*, Res.Obs, Res.Result  
SELECT Temp.*, Res.Obs, Res.Result  
FROM  (SELECT Cell.Obj_id_v AS Object, Cell_id AS Cell, Cell.Obj_id_r AS Upload, Obj.Ident, Obj.Name, N, GROUP_CONCAT(Loc.Location SEPARATOR ', ') AS Location, Obj.Unit, Mean, SD FROM Obj
FROM  (SELECT Cell.Obj_id_v AS Object, Cell_id AS Cell, Cell.Obj_id_r AS Upload, Obj.Ident, Obj.Name, N, GROUP_CONCAT(Loc.Location SEPARATOR ', ') AS Location, Obj.Unit, Mean, SD  
JOIN (SELECT Obj_id_v, MAX(Obj_id_r) AS Obj_id_r FROM
FROM (SELECT Obj_id_v, Obj_id_r FROM Obj JOIN Cell ON Obj.id=Cell.Obj_id_v WHERE Obj.Ident="Op_en{{PAGEID}}" ORDER BY Obj_id_r DESC LIMIT 0,1) AS Newest, Obj
(SELECT * FROM Cell
GROUP BY Obj_id_v, Obj_id_r) AS Temp
GROUP BY Obj_id_v) AS Newest ON Obj.id=Newest.Obj_id_v
JOIN Cell ON Obj.id=Cell.Obj_id_v  
JOIN Cell ON Obj.id=Cell.Obj_id_v  
JOIN Loccell ON Cell.id=Loccell.Cell_id  
JOIN Loccell ON Cell.id=Loccell.Cell_id  

Revision as of 19:49, 5 June 2009

Show results from the Opasnet Base:

{{#sql-query: SELECT Var.Ident, Var.Name, Var.Unit, Run.Ident, Objinfo.Moment, Objinfo.Who, Run.Name as Method FROM Obj JOIN Cell ON Var.id = Cell.Obj_id_v JOIN Obj AS Run ON Run.id = Cell.Obj_id_r JOIN Objinfo ON Run.id = Objinfo.Obj_id WHERE Var.Ident = "Op_en2239" GROUP BY Var.id, Run.id ORDER BY Run.id DESC |List of uploads|Resultlink}} | The newest upload | {{#sql-query: SELECT Cell.Obj_id_v AS Object, Cell_id AS Cell, Cell.Obj_id_r AS Upload, Obj.Ident, Obj.Name, N, GROUP_CONCAT(Loc.Location SEPARATOR ', ') AS Location, Obj.Unit, Mean, SD FROM (SELECT Obj_id_v, Obj_id_r FROM Obj JOIN Cell ON Obj.id=Cell.Obj_id_v WHERE Obj.Ident="Op_en2239" ORDER BY Obj_id_r DESC LIMIT 0,1) AS Newest, Obj JOIN Cell ON Obj.id=Cell.Obj_id_v JOIN Loccell ON Cell.id=Loccell.Cell_id JOIN Loc AS Rawloc ON Loccell.Loc_id=Rawloc.id JOIN Loc ON Rawloc.Std_id=Loc.id JOIN Obj AS Ind ON Loc.Obj_id_i=Ind.id WHERE Obj.Ident="Op_en2239" AND Cell.Obj_id_r=Newest.Obj_id_r GROUP BY Cell_id LIMIT 0, 1000 |Mean and SD}} | {{#sql-query: SELECT Temp.*, Res.Obs, Res.Result FROM (SELECT Cell.Obj_id_v AS Object, Cell_id AS Cell, Cell.Obj_id_r AS Upload, Obj.Ident, Obj.Name, N, GROUP_CONCAT(Loc.Location SEPARATOR ', ') AS Location, Obj.Unit, Mean, SD FROM (SELECT Obj_id_v, Obj_id_r FROM Obj JOIN Cell ON Obj.id=Cell.Obj_id_v WHERE Obj.Ident="Op_en2239" ORDER BY Obj_id_r DESC LIMIT 0,1) AS Newest, Obj JOIN Cell ON Obj.id=Cell.Obj_id_v JOIN Loccell ON Cell.id=Loccell.Cell_id JOIN Loc AS Rawloc ON Loccell.Loc_id=Rawloc.id JOIN Loc ON Rawloc.Std_id=Loc.id JOIN Obj AS Ind ON Loc.Obj_id_i=Ind.id WHERE Obj.Ident="Op_en2239" AND Cell.Obj_id_r=Newest.Obj_id_r GROUP BY Cell_id) AS Temp JOIN Res ON Temp.Cell=Res.Cell_id WHERE Obs<101 LIMIT 0, 1000 |Sample (max 100 iterations)}}

USAGE:
This template creates a link to a variable in result database.
First parameter is number of samples.

Development idea: Templaatti avaa tuloksen uuteen ikkunaan. Siellä on linkki, jota klikkaamalla tulee compare versions muuttujan nykyisestä wikisivusta ja siitä, joka oli voimassa sillä hetkellä kun muuttuja laskettiin tulostietokantaan.