From ad09c3ec72f238e260ec1e9f1abc5cc3a2789232 Mon Sep 17 00:00:00 2001 From: philippe lhardy Date: Sun, 28 Sep 2025 09:50:55 +0200 Subject: [PATCH] update pending --- README.md | 10 +++++-- code/convert_nextcloud_poll_csv.py | 36 ++++++++++++------------- etude/existant.md | 2 -- nextcloud_devenv/logs.sh | 4 +++ nextcloud_devenv/reset_polls.sh | 6 +++++ samples/nextcloud_poll_export/poll1.csv | 5 +++- 6 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 nextcloud_devenv/logs.sh create mode 100755 nextcloud_devenv/reset_polls.sh diff --git a/README.md b/README.md index ed6fc6b..9d477ce 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ https://en.wikipedia.org/wiki/Majority_judgment After some research most of implementation is done in https://github.com/MieuxVoter - Sorry for inconvenience but currently only french version is available. LISEZMOI.md @@ -50,4 +49,11 @@ dev done on Ubuntu 24.04.2 LTS ``` cd code ./check_csv.sh ../samples/nextcloud_poll_export/poll1.csv -``` \ No newline at end of file +``` + +``` +./check_csv.sh ../samples/nextcloud_poll_export/poll1.csv >../samples/0.json +``` + +et tester + diff --git a/code/convert_nextcloud_poll_csv.py b/code/convert_nextcloud_poll_csv.py index 3ed4b4e..0093c1b 100644 --- a/code/convert_nextcloud_poll_csv.py +++ b/code/convert_nextcloud_poll_csv.py @@ -3,41 +3,41 @@ import sys import csv # using non modified nextcloud standard text poll -nom_mentions=['yes','maybe','','no'] +mentions_name=['yes','maybe','','no'] if len(sys.argv) > 1: csv_file=sys.argv[1] if len(sys.argv) > 2: - nom_mentions=[] + mentions_name=[] for i in range(2,len(sys.argv)): - nom_mentions.append(sys.argv[i]) + mentions_name.append(sys.argv[i]) else: print('missing file argument') exit(1) def mention_index(mention): - return nom_mentions.index(mention) + return mentions_name.index(mention) verbose=False -mentions=len(nom_mentions) +mentions=len(mentions_name) default_mention=mentions-1 warnings=[] -candidats={} -candidats_alias=[] +candidates={} +candidates_alias=[] a_vote={} votes=[] with open(csv_file,'r') as csv_fd: vote_reader = csv.reader(csv_fd, delimiter=',') for row in vote_reader: - if len(candidats_alias) == 0: + if len(candidates_alias) == 0: for i in range(2,len(row)): - candidat_alias=row[i] - candidats_alias.append(candidat_alias) + candidate_alias=row[i] + candidates_alias.append(candidate_alias) # no other name given - if not candidat_alias in candidats: - candidats[candidat_alias]=candidat_alias + if not candidate_alias in candidates: + candidates[candidate_alias]=candidate_alias else: # check if not duplicated participant=row[0] @@ -47,20 +47,20 @@ with open(csv_file,'r') as csv_fd: a_vote[participant]=row[1] vote={} for i in range(2,len(row)): - candidat_index=i-2 - candidat_alias=candidats_alias[candidat_index] + candidate_index=i-2 + candidate_alias=candidates_alias[candidate_index] mention=row[i] - vote[candidat_alias]=mention_index(mention) + vote[candidate_alias]=mention_index(mention) votes.append(vote) default_vote={} if verbose: - print(','.join(candidats)) - print(','.join(nom_mentions)) + print(','.join(candidates)) + print(','.join(mentions_name)) -result = {'candidats':candidats,'votants':{'decompte':len(a_vote)},'mentions':nom_mentions,'votation':{'votes':votes}} +result = {'candidates':candidates,'voters':{'count':len(a_vote)},'mentions':mentions_name,'votation':{'votes':votes}} print(json.dumps(result)) sys.exit(0) diff --git a/etude/existant.md b/etude/existant.md index cfd8721..b5b6001 100644 --- a/etude/existant.md +++ b/etude/existant.md @@ -1,9 +1,7 @@ - # contexte Choix des noms de mentions - https://fr.wikipedia.org/wiki/Jugement_majoritaire vs https://en.wikipedia.org/wiki/Jugement_majoritaire diff --git a/nextcloud_devenv/logs.sh b/nextcloud_devenv/logs.sh new file mode 100644 index 0000000..2766462 --- /dev/null +++ b/nextcloud_devenv/logs.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +nextcloud_storage=/var/wwww/http/data +sudo -u www-data tail -f $nextcloud_storage/nextcloud.log diff --git a/nextcloud_devenv/reset_polls.sh b/nextcloud_devenv/reset_polls.sh new file mode 100755 index 0000000..8119125 --- /dev/null +++ b/nextcloud_devenv/reset_polls.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +./get_dbcontent.sh +./run_occ.sh polls:db:purge +./run_occ.sh app:enable polls +./run_occ.sh polls:db:rebuild diff --git a/samples/nextcloud_poll_export/poll1.csv b/samples/nextcloud_poll_export/poll1.csv index ff82bc9..b3ebb5c 100644 --- a/samples/nextcloud_poll_export/poll1.csv +++ b/samples/nextcloud_poll_export/poll1.csv @@ -1,2 +1,5 @@ Participants,Adresse e-mail,A,B,C -admin,,Très Bien,Bien,Assez Bien \ No newline at end of file +admin,,Très Bien,Bien,Assez Bien +user1,,Très Bien,Bien,Assez Bien +user2,,Très Bien,Bien,Assez Bien +user3,,Très Bien,Bien,Assez Bien \ No newline at end of file