Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add default colors to Referendum results #165

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This project is built by amazing volunteers and you can be one of them! Here's a
If you would like to suggest new functionality, open an Issue and mark it as a __[Feature request]__. Please be specific about why you think this functionality will be of use. If you can, please include some visual description of what you would like the UI to look like, if you are suggesting new UI elements.

## Built With

.Net Core 3.1


## Repos and projects
Expand All @@ -31,13 +31,25 @@ Client App - https://github.com/code4romania/rezultate-vot-client

## Deployment

Guide users through getting your code up and running on their own system. In this section you can talk about:
1. Installation process
2. Software dependencies
3. Latest releases
4. API references
1. install [.NetCore 3.1](https://dotnet.microsoft.com/download/dotnet/3.1)
* (optional) install [.NET for VSCode](https://dotnet.microsoft.com/download/dotnet/sdk-for-vs-code)

2. run the following console command from the `src` folder:
```sh
src> dotnet restore
```
If this fails with `error NU1100: Unable to resolve 'ExcelToJsonParser'` you might need to run first `dotnet nuget add source --name nuget.org https://api.nuget.org/v3/index.json`

3. run the following console command from the `ElectionResults.API` folder:
```sh
src\ElectionResults.API> dotnet run
```

4. browse to indicated address: http://localhost:5000/swagger (production api: https://api.rezultatevot.ro/swagger)

## Testing out the API

Describe and show how to build your code and run the tests.
Use the [Swagger UI](https://api.rezultatevot.ro/swagger) to understand the endpoints and routes. The API endpoints are public and do not require Authorization.

## Feedback

Expand Down
3 changes: 3 additions & 0 deletions src/ElectionResults.Core/Elections/ResultsProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,21 @@ public static ElectionResultsResponse PopulateElectionResults(Turnout electionTu
Name = "DA",
ShortName = "DA",
Votes = candidates.FirstOrDefault().YesVotes,
PartyColor = Consts.ReferendumYesColor,
},
new CandidateResponse
{
Name = "NU",
ShortName = "NU",
Votes = candidates.FirstOrDefault().NoVotes,
PartyColor = Consts.ReferendumNoColor,
},
new CandidateResponse
{
Name = "NU AU VOTAT",
ShortName = "NU AU VOTAT",
Votes = (results.EligibleVoters - results.TotalVotes).GetValueOrDefault(),
PartyColor = Consts.ReferendumNoneColor,
}
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/ElectionResults.Core/Elections/WinnersAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ private static ElectionMapWinner CreateElectionMapWinner(int? divisionId, Ballot
electionMapWinner.Winner.Name = "NU AU VOTAT";
electionMapWinner.Winner.ShortName = "NU AU VOTAT";
electionMapWinner.Winner.Votes = turnoutForDivision.EligibleVoters - turnoutForDivision.TotalVotes;
electionMapWinner.Winner.PartyColor = Consts.ReferendumNoneColor;
}
else
{
Expand All @@ -338,12 +339,14 @@ private static ElectionMapWinner CreateElectionMapWinner(int? divisionId, Ballot
electionMapWinner.Winner.Name = "DA";
electionMapWinner.Winner.ShortName = "DA";
electionMapWinner.Winner.Votes = winner.YesVotes;
electionMapWinner.Winner.PartyColor = Consts.ReferendumYesColor;
}
else
{
electionMapWinner.Winner.Name = "NU";
electionMapWinner.Winner.ShortName = "NU";
electionMapWinner.Winner.Votes = winner.NoVotes;
electionMapWinner.Winner.PartyColor = Consts.ReferendumNoColor;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/ElectionResults.Core/Infrastructure/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ public class Consts
public const string IndependentCandidateColor = "#808080";
public const int MinoritiesCountyId = 16821;
public const int CapitalCity = 12913;
public const string ReferendumYesColor = "#6540bf";
public const string ReferendumNoColor = "#40bf9b";
public const string ReferendumNoneColor = "#97bf40";
}
}