Improve user history logging

This commit is contained in:
Phillip Thelen
2024-09-06 13:47:41 +02:00
parent 86ea34f0be
commit cd94aeeb1a
4 changed files with 18 additions and 4 deletions
@@ -97,7 +97,7 @@
</th>
</tr>
<tr
v-for="entry in questInvites"
v-for="entry in questInviteResponses"
:key="entry.timestamp"
>
<td>
@@ -125,6 +125,9 @@
<th v-once>
Client
</th>
<th v-once>
Checkin Count
</th>
</tr>
<tr
v-for="entry in cron"
@@ -136,6 +139,7 @@
>{{ entry.timestamp | timeAgo }}</span>
</td>
<td>{{ entry.client }}</td>
<td>{{ entry.checkinCount }}</td>
</tr>
</table>
</div>
+1 -1
View File
@@ -525,7 +525,7 @@ export async function cron (options = {}) {
trackCronAnalytics(analytics, user, _progress, options);
await UserHistory.beginUserHistoryUpdate(user._id, options.headers)
.withCron()
.withCron(user.flags.cronCount)
.commit();
return _progress;
+9 -1
View File
@@ -38,6 +38,7 @@ import stripePayments from '../libs/payments/stripe'; // eslint-disable-line imp
import { getGroupChat, translateMessage } from '../libs/chat/group-chat'; // eslint-disable-line import/no-cycle
import { model as UserNotification } from './userNotification';
import { sendChatPushNotifications } from '../libs/chat'; // eslint-disable-line import/no-cycle
import { model as UserHistory } from './userHistory'; // eslint-disable-line import/no-cycle
const questScrolls = shared.content.quests;
const { questSeriesAchievements } = shared.content;
@@ -679,7 +680,8 @@ schema.methods.startQuest = async function startQuest (user) {
}
const nonMembers = Object.keys(_.pickBy(this.quest.members, member => !member));
const noResponseMembers = Object.keys(_.pickBy(this.quest.members, member => member === null));
console.log(this.quest.members, nonMembers, noResponseMembers);
// Changes quest.members to only include participating members
this.quest.members = _.pickBy(this.quest.members, _.identity);
@@ -751,6 +753,12 @@ schema.methods.startQuest = async function startQuest (user) {
_id: { $in: nonMembers },
}, _cleanQuestParty()).exec();
noResponseMembers.forEach(member => {
UserHistory.beginUserHistoryUpdate(member)
.withQuestInviteResponse(this.quest.key, 'no response')
.commit();
});
const newMessage = await this.sendChat({
message: `\`${shared.i18n.t('chatQuestStarted', { questName: quest.text('en') }, 'en')}\``,
metaData: {
+3 -1
View File
@@ -34,6 +34,7 @@ export const schema = new Schema({
{
_id: false,
timestamp: { $type: Date, required: true },
checkinCount: { $type: Number, required: true },
client: { $type: String, required: false },
},
],
@@ -110,9 +111,10 @@ model.beginUserHistoryUpdate = function beginUserHistoryUpdate (userID, headers
});
return this;
},
withCron: function withCron () {
withCron: function withCron (checkinCount) {
this.data.cron.push({
timestamp: new Date(),
checkinCount,
client: this.data.headers['x-client'],
});
return this;