diff --git a/db/seeds/08_dummy_announcement_authors.js b/db/seeds/08_dummy_announcement_authors.js new file mode 100644 index 0000000000000000000000000000000000000000..154dd90f00ea023204cca5997e93109a87e3d81d --- /dev/null +++ b/db/seeds/08_dummy_announcement_authors.js @@ -0,0 +1,25 @@ + +exports.seed = async function (knex, Promise) { + // Deletes ALL existing entries + await knex('announcements_authors').del(); + // Inserts seed entries + const announcements_authors = [{ + mid: 0, + gid: 'br' + },{ + mid: 1, + gid: 'jtx' + },{ + mid: 2, + gid: 'x-chine' + },{ + mid: 3, + gid: 'br' + },{ + mid: 4, + gid: 'federez' + } + ]; + return knex('announcements_authors').insert(announcements_authors) + .then(console.log("finished running 04_dummy_announcements")); +}; diff --git a/src/graphql/models/messageModel.ts b/src/graphql/models/messageModel.ts index a2b20b8400351ff2f2159fb375375c4507a53ee6..c3a2f92fb23150448ac1b821f4ce133d95f3fe2f 100644 --- a/src/graphql/models/messageModel.ts +++ b/src/graphql/models/messageModel.ts @@ -112,7 +112,6 @@ export class MessageModel { */ async getAllAnnouncements(groups: GroupSet): Promise<Announcement[]> { throw "Not implemented"; - /*let result = await knex.select().from('announcements').whereIn('id', selection); result = result.concat( await knex.select().from('events').whereIn('id', selection) @@ -133,8 +132,9 @@ export class MessageModel { * @rights member of groups */ async getAllAnnouncementsSent(groups: GroupSet): Promise<Announcement[]> { - throw "Not implemented"; - + let announces = await knex.distinct('mid').select().from('announcements_authors').whereIn('gid', [...groups]); + return announces.map(elt => new Announcement(elt.mid)); + /*let result = await knex.select().from('announcements').whereIn('gid'); result = result.concat( await knex.select().from('events').whereIn('id')