|
@@ -2996,7 +2996,7 @@ async function appStudentCompanionOverview(input,current,uid,p) {
|
|
|
const stored=await Psql.query('SELECT c."generalId",c."title",c."createTime",c."status" AS "commonStatus",a.*,n."nodeName" AS "courseTitle" FROM "CourseAppointment" a LEFT JOIN "CommonModel" c ON c."company"=a."company" AND c."modelId"=54 AND c."itemId"=a."id" LEFT JOIN "Node" n ON n."company"=a."company" AND n."nodeId"::text=a."kcid" WHERE a."company"=$1 AND a."szyh"=$2 ORDER BY a."yysj" ASC,a."id" DESC LIMIT 5000',[DEFAULT_COMPANY_ID,String(uid)]),liveRows=legacyAppointmentSync.state==='current'?legacyAppointmentSync.items:[],merged=mergeCompanionRows(stored.map(appOverviewScheduleRow),liveRows),search=String(input.search||'').trim().toLocaleLowerCase('zh-CN'),month=/^\d{4}-\d{2}$/.test(String(input.month||''))?String(input.month):'',today=appOverviewToday();
|
|
const stored=await Psql.query('SELECT c."generalId",c."title",c."createTime",c."status" AS "commonStatus",a.*,n."nodeName" AS "courseTitle" FROM "CourseAppointment" a LEFT JOIN "CommonModel" c ON c."company"=a."company" AND c."modelId"=54 AND c."itemId"=a."id" LEFT JOIN "Node" n ON n."company"=a."company" AND n."nodeId"::text=a."kcid" WHERE a."company"=$1 AND a."szyh"=$2 ORDER BY a."yysj" ASC,a."id" DESC LIMIT 5000',[DEFAULT_COMPANY_ID,String(uid)]),liveRows=legacyAppointmentSync.state==='current'?legacyAppointmentSync.items:[],merged=mergeCompanionRows(stored.map(appOverviewScheduleRow),liveRows),search=String(input.search||'').trim().toLocaleLowerCase('zh-CN'),month=/^\d{4}-\d{2}$/.test(String(input.month||''))?String(input.month):'',today=appOverviewToday();
|
|
|
let base=merged.filter((row)=>history?(row.cancelled===true||number(row.dszt)>=30):row.cancelled!==true);if(search)base=base.filter((row)=>(String(row.Title||'')+' '+String(row.Title2||'')+' '+String(row.plxm||'')).toLocaleLowerCase('zh-CN').includes(search));if(month)base=base.filter((row)=>companionDateKey(row).startsWith(month+'-'));
|
|
let base=merged.filter((row)=>history?(row.cancelled===true||number(row.dszt)>=30):row.cancelled!==true);if(search)base=base.filter((row)=>(String(row.Title||'')+' '+String(row.Title2||'')+' '+String(row.plxm||'')).toLocaleLowerCase('zh-CN').includes(search));if(month)base=base.filter((row)=>companionDateKey(row).startsWith(month+'-'));
|
|
|
const dateMap=new Map();for(const row of base){const date=companionDateKey(row);if(!date)continue;const value=dateMap.get(date)||{date,finished:0,planned:0};if(number(row.dszt)>=30&&row.cancelled!==true)value.finished++;else if(row.cancelled!==true)value.planned++;dateMap.set(date,value);}const dates=[...dateMap.values()].sort((left,right)=>left.date.localeCompare(right.date));
|
|
const dateMap=new Map();for(const row of base){const date=companionDateKey(row);if(!date)continue;const value=dateMap.get(date)||{date,finished:0,planned:0};if(number(row.dszt)>=30&&row.cancelled!==true)value.finished++;else if(row.cancelled!==true)value.planned++;dateMap.set(date,value);}const dates=[...dateMap.values()].sort((left,right)=>left.date.localeCompare(right.date));
|
|
|
- let filtered=base;if(input.dateStart)filtered=filtered.filter((row)=>companionDateKey(row)>=String(input.dateStart));if(input.dateEnd)filtered=filtered.filter((row)=>companionDateKey(row)<=String(input.dateEnd));if(input.filter==='finished')filtered=filtered.filter((row)=>number(row.dszt)>=30&&row.cancelled!==true);if(input.filter==='pending')filtered=filtered.filter((row)=>number(row.dszt)<30&&row.cancelled!==true&&companionDateKey(row)<today);filtered.sort((left,right)=>{const order=(companionDateKey(left)+' '+String(left.yysj||left.sdsd||'')).localeCompare(companionDateKey(right)+' '+String(right.yysj||right.sdsd||''));return history?-order:order;});
|
|
|
|
|
|
|
+ let filtered=base;if(input.dateStart)filtered=filtered.filter((row)=>companionDateKey(row)>=String(input.dateStart));if(input.dateEnd)filtered=filtered.filter((row)=>companionDateKey(row)<=String(input.dateEnd));if(input.filter==='finished')filtered=filtered.filter((row)=>number(row.dszt)>=30&&row.cancelled!==true);if(input.filter==='pending')filtered=filtered.filter((row)=>number(row.dszt)<30&&row.cancelled!==true&&companionDateKey(row)<today);filtered.sort((left,right)=>{const order=(companionDateKey(left)+' '+String(left.yysj||left.sdsd||'')).localeCompare(companionDateKey(right)+' '+String(right.yysj||right.sdsd||''));return history||input.filter==='finished'?-order:order;});
|
|
|
const total=filtered.length,offset=(p.index-1)*p.size,schedules=filtered.slice(offset,offset+p.size),courses=await Psql.query('SELECT c."generalId",c."title",b.*,b."objectId" AS "bindingObjectId",n."nodeName" AS "courseTitle" FROM "CourseBinding" b JOIN "CommonModel" c ON c."company"=b."company" AND c."modelId"=58 AND c."itemId"=b."id" LEFT JOIN "Node" n ON n."company"=b."company" AND n."nodeId"::text=b."kcid" WHERE b."company"=$1 AND b."yhid"=$2 AND b."enrollmentStatus"=\'active\' AND c."status"=99 AND COALESCE(n."zstatus",99)=99 ORDER BY b."id" DESC',[DEFAULT_COMPANY_ID,String(uid)]),scopes=['courses','appointments'],live=withLegacyAppointmentVersion(await appLiveVersionSnapshot(uid,scopes,current),scopes,legacyAppointmentSync);
|
|
const total=filtered.length,offset=(p.index-1)*p.size,schedules=filtered.slice(offset,offset+p.size),courses=await Psql.query('SELECT c."generalId",c."title",b.*,b."objectId" AS "bindingObjectId",n."nodeName" AS "courseTitle" FROM "CourseBinding" b JOIN "CommonModel" c ON c."company"=b."company" AND c."modelId"=58 AND c."itemId"=b."id" LEFT JOIN "Node" n ON n."company"=b."company" AND n."nodeId"::text=b."kcid" WHERE b."company"=$1 AND b."yhid"=$2 AND b."enrollmentStatus"=\'active\' AND c."status"=99 AND COALESCE(n."zstatus",99)=99 ORDER BY b."id" DESC',[DEFAULT_COMPANY_ID,String(uid)]),scopes=['courses','appointments'],live=withLegacyAppointmentVersion(await appLiveVersionSnapshot(uid,scopes,current),scopes,legacyAppointmentSync);
|
|
|
return{schedules,courses:courses.map(appOverviewCourseRow),page:mobilePageMeta(total,p),dates,studentOptions:[],...mobileSource(),...live};
|
|
return{schedules,courses:courses.map(appOverviewCourseRow),page:mobilePageMeta(total,p),dates,studentOptions:[],...mobileSource(),...live};
|
|
|
}
|
|
}
|
|
@@ -3020,7 +3020,7 @@ async function appCompanionOverview(input,current) {
|
|
|
if(input.filter==='finished')clauses.push('a."dszt"::numeric>=30 AND COALESCE(c."status",99)<>-2');
|
|
if(input.filter==='finished')clauses.push('a."dszt"::numeric>=30 AND COALESCE(c."status",99)<>-2');
|
|
|
if(input.filter==='pending'){clauses.push('a."dszt"::numeric<30 AND COALESCE(c."status",99)<>-2');add(date+'<?',appOverviewToday());}
|
|
if(input.filter==='pending'){clauses.push('a."dszt"::numeric<30 AND COALESCE(c."status",99)<>-2');add(date+'<?',appOverviewToday());}
|
|
|
const where=clauses.join(' AND '),readCount=()=>Psql.one('SELECT COUNT(*)::int total'+join+' WHERE '+where,args);
|
|
const where=clauses.join(' AND '),readCount=()=>Psql.one('SELECT COUNT(*)::int total'+join+' WHERE '+where,args);
|
|
|
- const readRows=()=>Psql.query('SELECT c."generalId",c."title",c."createTime",c."status" AS "commonStatus",a.*,n."nodeName" AS "courseTitle"'+join+' LEFT JOIN "Node" n ON n."company"=a."company" AND n."nodeId"::text=a."kcid" WHERE '+where+' ORDER BY a."yysj" '+(history?'DESC':'ASC')+',a."id" DESC LIMIT $'+(args.length+1)+' OFFSET $'+(args.length+2),[...args,p.size,(p.index-1)*p.size]);
|
|
|
|
|
|
|
+ const readRows=()=>Psql.query('SELECT c."generalId",c."title",c."createTime",c."status" AS "commonStatus",a.*,n."nodeName" AS "courseTitle"'+join+' LEFT JOIN "Node" n ON n."company"=a."company" AND n."nodeId"::text=a."kcid" WHERE '+where+' ORDER BY a."yysj" '+(history||input.filter==='finished'?'DESC':'ASC')+',a."id" DESC LIMIT $'+(args.length+1)+' OFFSET $'+(args.length+2),[...args,p.size,(p.index-1)*p.size]);
|
|
|
const readCourses=()=>coach?[]:Psql.query('SELECT c."generalId",c."title",b.*,b."objectId" AS "bindingObjectId",n."nodeName" AS "courseTitle" FROM "CourseBinding" b JOIN "CommonModel" c ON c."company"=b."company" AND c."modelId"=58 AND c."itemId"=b."id" LEFT JOIN "Node" n ON n."company"=b."company" AND n."nodeId"::text=b."kcid" WHERE b."company"=$1 AND b."yhid"=$2 AND b."enrollmentStatus"=\'active\' AND c."status"=99 AND COALESCE(n."zstatus",99)=99 ORDER BY b."id" DESC',[DEFAULT_COMPANY_ID,String(uid)]);
|
|
const readCourses=()=>coach?[]:Psql.query('SELECT c."generalId",c."title",b.*,b."objectId" AS "bindingObjectId",n."nodeName" AS "courseTitle" FROM "CourseBinding" b JOIN "CommonModel" c ON c."company"=b."company" AND c."modelId"=58 AND c."itemId"=b."id" LEFT JOIN "Node" n ON n."company"=b."company" AND n."nodeId"::text=b."kcid" WHERE b."company"=$1 AND b."yhid"=$2 AND b."enrollmentStatus"=\'active\' AND c."status"=99 AND COALESCE(n."zstatus",99)=99 ORDER BY b."id" DESC',[DEFAULT_COMPANY_ID,String(uid)]);
|
|
|
const readAllRows=()=>coach&&history?Psql.query('SELECT c."generalId",c."status" AS "commonStatus",a.dszt'+join+' WHERE '+where,args):[];
|
|
const readAllRows=()=>coach&&history?Psql.query('SELECT c."generalId",c."status" AS "commonStatus",a.dszt'+join+' WHERE '+where,args):[];
|
|
|
// Each request reads fresh data; only independent reads overlap, with bounded database pressure.
|
|
// Each request reads fresh data; only independent reads overlap, with bounded database pressure.
|