Skip to content
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
5 changes: 1 addition & 4 deletions backend/howtheyvote/models/vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,5 @@ def display_title(self) -> str | None:
return self.title or self.procedure_title

@property
def sharepic_url(self) -> str | None:
if not self.is_main:
return None

def sharepic_url(self) -> str:
return url_for("api.static_api.vote_sharepic", vote_id=self.id)
4 changes: 0 additions & 4 deletions backend/howtheyvote/pipelines/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ def generate_vote_sharepics(votes: Iterable[Vote]) -> None:
success_count = 0

for vote in votes:
if not vote.is_main:
log.info("Skipping sharepic generation because vote is not main.", vote_id=vote.id)
continue

log.info("Generating vote sharepic.", vote_id=vote.id)

try:
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/api/test_votes_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def test_votes_api_show(records, db_session, api):
"stage": None,
},
"facts": None,
"sharepic_url": None,
"sharepic_url": "/api/static/votes/sharepic-1.png",
"stats": {
"total": {
"FOR": 1,
Expand Down
4 changes: 4 additions & 0 deletions backend/tests/worker/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@


def test_rcv_list_pipeline(db_session, mocker):
# Same as below, not patching these make the test extremely slow
mocker.patch("howtheyvote.pipelines.rcv_list.generate_vote_sharepics", return_value=None)
mocker.patch("howtheyvote.pipelines.vot_list.generate_vote_sharepics", return_value=None)

plenary_session = PlenarySession(
id="2025-07-07",
start_date=datetime.date(2025, 7, 7),
Expand Down
23 changes: 10 additions & 13 deletions frontend/src/pages/ShowVotePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,23 @@ function MetaTags({ vote }: { vote: Vote }) {
const stats = vote.stats.total;
const total = stats.FOR + stats.AGAINST + stats.ABSTENTION;

const altText = `A barchart visualizing the result of a European Parliament vote. The vote took place on ${date}, and is titled “${vote.display_title}”. The chart has three bars representing the ${stats.FOR} MEPs who voted in favor, the ${stats.AGAINST} MEPs who voted against, and the ${stats.ABSTENTION} MEPs who abstained. A total of ${total} MEPs participated in the vote and ${stats.DID_NOT_VOTE} did not vote.`;
const altText = `A barchart visualizing the result of a European Parliament vote. The vote took place on ${date}, and is titled “${vote.display_title + (vote.description ? ` - ${vote.description}` : "")}”. The chart has three bars representing the ${stats.FOR} MEPs who voted in favor, the ${stats.AGAINST} MEPs who voted against, and the ${stats.ABSTENTION} MEPs who abstained. A total of ${total} MEPs participated in the vote and ${stats.DID_NOT_VOTE} did not vote.`;
const title = `Vote results: ${vote.display_title}`;
const description =
"Find out how the Members of the European Parliament voted.";

return (
<>
{!vote.is_main && <meta name="robots" content="noindex" />}
{vote.sharepic_url && (
<>
<meta name="description" content={description} />
<meta property="og:site_name" content="HowTheyVote.eu" />
<meta property="og:type" content="article" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={vote.sharepic_url} />
<meta property="og:image:alt" content={altText} />
<meta property="article:published_time" content={vote.timestamp} />
</>
)}

<meta name="description" content={description} />
<meta property="og:site_name" content="HowTheyVote.eu" />
<meta property="og:type" content="article" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
<meta property="og:image" content={vote.sharepic_url} />
<meta property="og:image:alt" content={altText} />
<meta property="article:published_time" content={vote.timestamp} />
</>
);
}