Skip to content

Commit

Permalink
lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Fattimo committed Apr 13, 2021
1 parent 5ac26e2 commit b9cadc0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module.exports = {
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
'@typescript-eslint/no-var-requires': 'warn',
},
};
}
5 changes: 2 additions & 3 deletions MassMessage/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AzureFunction, Context } from '@azure/functions'
import Mongoose from 'mongoose'

import UserState from '../models/UserState'
import MongoConnect from '../db'
Expand Down Expand Up @@ -48,7 +47,7 @@ const messageInactiveUsers = async function (date: Date) {
},
})
allUsers.forEach(async (user) => {
sendInactiveMessage(user.userId, twoWeeks.toDateString(), user.lowData)
sendInactiveMessage(user.userId)
//hardcoded to welcome message
user.currMessage = (await fixedMessages.get('welcome'))._id
user.save((err) => {
Expand Down Expand Up @@ -94,7 +93,7 @@ const messageCompletedUsers = async function (date: Date) {
return x || x >= 0
})

sendCompletedMessage(user, user.userId, twoMonths.toDateString(), modules, user.lowData)
sendCompletedMessage(user, user.userId, twoMonths.toDateString(), modules)

/*
modules.forEach(mod => {
Expand Down
4 changes: 2 additions & 2 deletions ReceiveMessage/Scripts/readRequest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import qs from 'qs'
import MongoConnect from '../../db'
import UserState from '../../models/UserState'
import UserState, { IUserState } from '../../models/UserState'

//change to Promise<UserState> later
const getUserState = async function (req: HttpRequest) {
const getUserState = async function (req: HttpRequest): Promise<IUserState> {
const body = qs.parse(req.body)
// do necessary processing on the request (nothing at this point)
await MongoConnect()
Expand Down
20 changes: 10 additions & 10 deletions db.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import mongoose from 'mongoose';
import mongoose from 'mongoose'

import config from './config';
import config from './config'

const MongoConnect = async () => {
if (mongoose.connections[0].readyState) return;
const MongoConnect = async (): Promise<void> => {
if (mongoose.connections[0].readyState) return

await mongoose
.connect(config.db.url, {
...config.db.options,
dbName: config.db.name,
})
.catch((error) => {
console.error('Database connection failed. 👇🏼');
console.error(' > ' + error);
console.error('Database connection failed. 👇🏼')
console.error(' > ' + error)

throw error;
});
};
throw error
})
}

export default MongoConnect;
export default MongoConnect
14 changes: 7 additions & 7 deletions models/MessageResponse.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import mongoose, { Schema, Document } from 'mongoose';
import mongoose, { Schema, Document } from 'mongoose'

const MessageResponseSchema : Schema = new Schema({
const MessageResponseSchema: Schema = new Schema({
accountID: { type: String, required: true },
chatBotMessageID: { type: String, required: true },
response: { type: String, required: true },
});
})

export interface IMessageResponse extends Document {
accountID: string;
chatBotMessageID: string;
response: string;
accountID: string
chatBotMessageID: string
response: string
}

export default mongoose.model<IMessageResponse>('MessageResponse', MessageResponseSchema);
export default mongoose.model<IMessageResponse>('MessageResponse', MessageResponseSchema)
5 changes: 2 additions & 3 deletions models/UserState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import mongoose, { Schema, Document } from 'mongoose'
import { IMessage } from './ChatbotMessage'


export interface IUserState extends Document {
userId: string
currMessage: IMessage['_id']
Expand All @@ -21,8 +20,8 @@ const UserStateSchema = new Schema({
},
lowData: { type: Boolean },
moduleCompletionTime: { type: [Date], default: [null, null, null, null, null] },
dataConsent: { type: Boolean, required: true},
dataConsent: { type: Boolean, required: true },
lastActivity: { type: Date },
})

export default mongoose.model<IUserState>('UserState', UserStateSchema);
export default mongoose.model<IUserState>('UserState', UserStateSchema)

0 comments on commit b9cadc0

Please sign in to comment.