|
@@ -1,4 +1,4 @@
|
|
|
-const psqlDB = require("./psql.service");
|
|
|
+const psqlDB = require("../psql.service");
|
|
|
|
|
|
class FaceService{
|
|
|
|
|
@@ -6,26 +6,32 @@ class FaceService{
|
|
|
limit = limit || 10;
|
|
|
|
|
|
let sql = `
|
|
|
- select "objectId" as id,"photo","createdAt", array_agg(item)::vector(128) <=> $1::vector(128) as cos
|
|
|
+ select "objectId" as id,"title","photo","createdAt", array_agg(item)::vector(128) <=> $1::vector(128) as cos
|
|
|
from (
|
|
|
SELECT *, jsonb_array_elements("feat68")::float AS item from (
|
|
|
- SELECT "objectId","photo","feat68","createdAt"
|
|
|
+ SELECT "objectId","photo","title","feat68","createdAt"
|
|
|
FROM "FaceReport"
|
|
|
WHERE "feat68" is not null
|
|
|
ORDER BY "createdAt" DESC
|
|
|
- limit ${limit}
|
|
|
) as rt1
|
|
|
) as rt
|
|
|
- GROUP BY "objectId",rt."photo","createdAt"
|
|
|
+ GROUP BY "objectId","title",rt."photo","createdAt"
|
|
|
+ ORDER BY cos limit ${limit};
|
|
|
`
|
|
|
let params = [feat68]
|
|
|
- let result = await psqlDB.any(sql,params)
|
|
|
+ let result
|
|
|
+ try{
|
|
|
+ result = await psqlDB.any(sql,params)
|
|
|
+ console.log(result)
|
|
|
+ }catch(err){
|
|
|
+ console.error(err)
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- result = result.filter(item=>item.cos<0.0385 && item.id!=report.id)
|
|
|
- result.sort((a,b)=>a.createdAt-b.createdAt)
|
|
|
+
|
|
|
+
|
|
|
if(result?.length>0){
|
|
|
console.log(result)
|
|
|
}
|