-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from seantis/fix-agenda-item-not-being-monton-a…
…scending Ensure `AgendaItem.position` values are strictly increasing.
- Loading branch information
Showing
11 changed files
with
244 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import click | ||
from pyramid.paster import bootstrap | ||
from pyramid.paster import get_appsettings | ||
from sqlalchemy import select | ||
from privatim.models import Meeting | ||
from privatim.orm import get_engine, Base | ||
|
||
|
||
from typing import TYPE_CHECKING | ||
if TYPE_CHECKING: | ||
from privatim.models import AgendaItem | ||
|
||
|
||
DEFAULT_MEETING_ID = '359d71d2-2162-4110-b021-a0239f7a3236' | ||
|
||
|
||
@click.command() | ||
@click.argument('config_uri') | ||
@click.option( | ||
'--meeting-id', default=DEFAULT_MEETING_ID, help='Meeting ID to analyze' | ||
) | ||
def main(config_uri: str, meeting_id: str) -> None: | ||
"""Analyze agenda items positions for a specific meeting.""" | ||
env = bootstrap(config_uri) | ||
settings = get_appsettings(config_uri) | ||
engine = get_engine(settings) | ||
Base.metadata.create_all(engine) | ||
|
||
with env['request'].tm: | ||
session = env['request'].dbsession | ||
|
||
meeting = session.execute( | ||
select(Meeting).where(Meeting.id == meeting_id) | ||
).scalar_one_or_none() | ||
|
||
if not meeting: | ||
print(f'Meeting with ID {meeting_id} not found') | ||
return | ||
if not meeting.agenda_items: | ||
print('\nNo agenda items found for this meeting') | ||
return | ||
|
||
print_agenda_items_positions(meeting.agenda_items) | ||
|
||
|
||
def print_agenda_items_positions(items: list['AgendaItem']) -> None: | ||
"""Print position and title of each agenda item.""" | ||
for item in sorted(items, key=lambda x: x.position): | ||
print(f'{item.position}. {item.title}') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.