Skip to content

Commit

Permalink
fix: 🐛 fix building common packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Ruck committed Oct 22, 2023
1 parent d07edff commit 1f6409f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
5 changes: 0 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ node_modules
git
infra
docker_volumes
democracy
data
configuration
common
bundestag.io
.vscode
.turbo
.github
34 changes: 13 additions & 21 deletions common/democracy/src/models/vote/schema.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Schema, Document, Types } from "mongoose";
import { IProcedure } from "models/procedure";
import { Phone } from "models/phone";
import { Device } from "models/device";
import { Schema, Document, Types } from 'mongoose';
import { IProcedure } from '../procedure';
import { Phone } from '../phone';
import { Device } from '../device';

export interface Vote extends Document {
procedure: IProcedure | Types.ObjectId;
state: "VOTING" | "COMPLETED";
type: "Phone" | "Device";
state: 'VOTING' | 'COMPLETED';
type: 'Phone' | 'Device';
voters: { voter: Types.ObjectId | Phone | Device }[];
votes: {
general: {
Expand All @@ -21,7 +21,7 @@ export interface Vote extends Document {
no: number;
abstain: number;
_id: false;
}
},
];
cache: {
yes: number;
Expand All @@ -34,14 +34,12 @@ export interface Vote extends Document {
const VoteSchema = new Schema<Vote>({
procedure: {
type: Schema.Types.ObjectId,
ref: "Procedure",
ref: 'Procedure',
required: true,
},
state: { type: String, enum: ["VOTING", "COMPLETED"], required: true },
type: { type: String, enum: ["Phone", "Device"], required: true },
voters: [
{ voter: { type: Schema.Types.ObjectId, refPath: "type" }, _id: false },
],
state: { type: String, enum: ['VOTING', 'COMPLETED'], required: true },
type: { type: String, enum: ['Phone', 'Device'], required: true },
voters: [{ voter: { type: Schema.Types.ObjectId, refPath: 'type' }, _id: false }],
votes: {
general: {
yes: { type: Number, default: 0 },
Expand All @@ -66,13 +64,7 @@ const VoteSchema = new Schema<Vote>({
});

VoteSchema.index({ procedure: 1, state: 1, type: 1 }, { unique: true });
VoteSchema.index(
{ procedure: 1, type: 1, "voters.voter": 1 },
{ unique: true }
);
VoteSchema.index(
{ _id: 1, "votes.constituencies.constituency": 1 },
{ unique: true }
);
VoteSchema.index({ procedure: 1, type: 1, 'voters.voter': 1 }, { unique: true });
VoteSchema.index({ _id: 1, 'votes.constituencies.constituency': 1 }, { unique: true });

export default VoteSchema;

0 comments on commit 1f6409f

Please sign in to comment.