Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/prerna/collaboration/BrainRuleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ static Map<String, Object> addRule(String ownerId, String ownerType, String kind
// a sender kept out leaves Work too; deleting the rule brings the items back
WorkItemUtils.dismissForRule(ownerId, ownerType, keptOutPeople(ownerId, ownerType, kind, value, personId),
ruleId);
// what a summary may say changed; each thread summarizes again when opened or when mail comes in
WorkThreadInsights.markStale(ownerId, ownerType, null);
return getRule(ownerId, ownerType, ruleId);
}

Expand Down Expand Up @@ -212,6 +214,7 @@ static void disable(String ownerId, String ownerType, String ruleId) {
reinclude(conn, ownerId, ownerType, ruleId);
});
WorkItemUtils.reopenForRule(ownerId, ownerType, ruleId);
WorkThreadInsights.markStale(ownerId, ownerType, null);
}

private static void reinclude(Connection conn, String ownerId, String ownerType, String ruleId)
Expand Down
9 changes: 8 additions & 1 deletion src/prerna/collaboration/BrainSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
import prerna.om.Insight;

// Refresh (and later the Collaboration webhook): mail and Teams since the last finished import or sync, through the
// same gate and classifier as onboarding, without its setup steps. One sync job per owner at a time.
// same gate and classifier as onboarding, without its setup steps, then queues the summaries and action items of the
// threads with new mail (WorkThreadInsights). One sync job per owner at a time.
public final class BrainSync {

public static final String KIND = "sync";
Expand Down Expand Up @@ -144,6 +145,12 @@ static void run(User user, CollaborationJobUtils.Job job, Timestamp last) throws
}
outcomes(job, ownerId, ownerType, touched, verdicts, startedAt);

// summaries and action items for the threads with new mail, on their own pool: the sync does not wait
Set<String> summarize = new LinkedHashSet<>(touched);
summarize.removeIf(id -> AUTOMATED.equals(verdicts.get(id)) || "skipped".equals(verdicts.get(id)));
WorkThreadInsights.queue(user, ownerId, ownerType, summarize);
job.count("summarizing", summarize.size());

CollaborationSourceUtils.recordSourceEvent(ownerId, ownerType, EMAIL);
if (withTeams && teamsError == null) {
CollaborationSourceUtils.recordSourceEvent(ownerId, ownerType, TEAMS);
Expand Down
16 changes: 15 additions & 1 deletion src/prerna/collaboration/BrainThreadUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,30 @@ public static Map<String, Object> listThreads(User user, String filter, String t
}

List<Map<String, Object>> items = CollaborationDbUtils.query(CollaborationDbUtils.page("SELECT "
+ THREAD_COLUMNS + ", t.SUMMARY, " + OPEN_TOPIC_CHOICE + " AS NEEDS_CHOICE FROM BRAIN_THREAD t" + where
+ THREAD_COLUMNS + ", t.SUMMARY, t.SUMMARY_REF, t.SUMMARY_AT, " + OPEN_TOPIC_CHOICE
+ " AS NEEDS_CHOICE FROM BRAIN_THREAD t" + where
+ " ORDER BY COALESCE(t.LAST_MESSAGE_AT, t.CREATED_AT) DESC, t.THREAD_ID", limit, offset), rs -> {
Map<String, Object> row = mapThread(rs);
if (detail) {
row.put("summary", CollaborationDbUtils.getString(rs, "SUMMARY"));
row.put("summaryRef", CollaborationDbUtils.getString(rs, "SUMMARY_REF"));
row.put("summaryAt", CollaborationDbUtils.getTimestamp(rs, "SUMMARY_AT"));
}
return row;
}, params.toArray());
addLinks(ownerId, ownerType, items);
if (detail) {
addParticipants(ownerId, ownerType, items);
addLatestMessage(ownerId, ownerType, items);
// whether the summary was made from the newest message, and whether one is being made now
for (Map<String, Object> row : items) {
String ref = (String) row.remove("summaryRef");
row.put("summaryAt", row.remove("summaryAt"));
row.put("summaryCurrent", WorkThreadInsights.covers(ref, (String) row.get("latestMessageId")));
if (WorkThreadInsights.isPending(ownerId, ownerType, (String) row.get("id"))) {
row.put("summaryPending", true);
}
}
}

Map<String, Object> page = new LinkedHashMap<>();
Expand Down Expand Up @@ -234,6 +246,8 @@ && isActiveRule(ownerId, ownerType, (String) current.get("ruleId"))) {
+ "WHERE OWNER_ID = ? AND OWNER_TYPE = ? AND THREAD_ID = ? AND PERSON_ID = ?",
included, included ? null : BrainProfileUtils.YOU, included ? null : CollaborationDbUtils.now(),
ownerId, ownerType, threadId, personId);
// the summary may hold what this person wrote, or miss it
WorkThreadInsights.markStale(ownerId, ownerType, threadId);
}
return CollaborationDbUtils.queryOne("SELECT tp.PERSON_ID, tp.ROLES_JSON, tp.INCLUDED, tp.EXCLUDED_BY, "
+ "tp.EXCLUDED_AT, tp.HIDDEN_COUNT, p.DISPLAY_NAME, p.EMAIL_NORM FROM BRAIN_THREAD_PARTICIPANT tp "
Expand Down
5 changes: 3 additions & 2 deletions src/prerna/collaboration/BrainTopicModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import prerna.util.Constants;
import prerna.util.Utility;

// Resolves the permitted platform text engine; BrainTopicStructure groups headers and BrainTopicVotes judges them.
// Resolves the permitted platform text engine; BrainTopicStructure groups headers and BrainTopicVotes judges them, and
// WorkThreadInsights writes thread summaries and action items with it.
final class BrainTopicModel {

private BrainTopicModel() {
Expand All @@ -49,7 +50,7 @@ static String engine(User user) {
}
if (!SecurityEngineUtils.userCanViewEngine(user, id.trim())) {
throw new IllegalArgumentException(
"You do not have access to the topic model (" + id.trim() + "); ask an admin to share it with you");
"You do not have access to Brain's text model (" + id.trim() + "); ask an admin to share it with you");
}
return id.trim();
}
Expand Down
6 changes: 6 additions & 0 deletions src/prerna/collaboration/CollaborationOwlCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ public void createColumnsAndTypes(AbstractSqlQueryUtil queryUtil) {
Pair.with("ROOM_ID", VARCHAR_50),
Pair.with("GOAL", CLOB_DATATYPE_NAME),
Pair.with("SUMMARY", CLOB_DATATYPE_NAME),
// the newest message the summary and generated steps were made from, and when
Pair.with("SUMMARY_REF", VARCHAR_255),
Pair.with("SUMMARY_AT", TIMESTAMP_DATATYPE_NAME),
Pair.with("MESSAGE_COUNT", INTEGER_DATATYPE_NAME),
Pair.with("LAST_MESSAGE_AT", TIMESTAMP_DATATYPE_NAME),
Pair.with("CREATED_AT", TIMESTAMP_DATATYPE_NAME)));
Expand Down Expand Up @@ -371,6 +374,9 @@ public void createColumnsAndTypes(AbstractSqlQueryUtil queryUtil) {
Pair.with("DUE_AT", TIMESTAMP_DATATYPE_NAME),
Pair.with("ITEM_ID", VARCHAR_50),
Pair.with("LINK_TOPIC_ID", VARCHAR_50),
// brain when thread insights made it; EDITED once the owner changes its text, owner, due or kind
Pair.with("ORIGIN", VARCHAR_20),
Pair.with("EDITED", BOOLEAN_DATATYPE_NAME),
Pair.with("CREATED_AT", TIMESTAMP_DATATYPE_NAME),
Pair.with("UPDATED_AT", TIMESTAMP_DATATYPE_NAME)));
addTable("WORK_THREAD_FACT", Arrays.asList(
Expand Down
Loading
Loading