@tricoteuses/senat 2.15.6 → 2.15.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,7 @@ function votes(scrutinNum, scrutinSession, scrutinDate) {
16
16
  ])))
17
17
  .where("dosleg.votsen.scrnum", "=", scrutinNum)
18
18
  .where("dosleg.votsen.sesann", "=", scrutinSession)
19
+ .orderBy("sens.memgrppol.memgrppoldatdeb", "desc")
19
20
  .select([
20
21
  "dosleg.votsen.senmat as matricule_votant",
21
22
  "dosleg.votsen.senmatdel as matricule_delegant",
@@ -26,6 +27,57 @@ function votes(scrutinNum, scrutinSession, scrutinDate) {
26
27
  "sens.memgrppol.grppolcod as groupe_politique_code",
27
28
  ]));
28
29
  }
30
+ function groupesVotants(scrutinNum, scrutinSession, scrutinDate) {
31
+ return jsonArrayFrom(dbSenat
32
+ .selectFrom((eb) => eb
33
+ .selectFrom("dosleg.votsen")
34
+ .leftJoin("dosleg.posvot", "dosleg.posvot.posvotcod", "dosleg.votsen.posvotcod")
35
+ .leftJoin("dosleg.stavot", "dosleg.stavot.stavotidt", "dosleg.votsen.stavotidt")
36
+ .leftJoin("sens.memgrppol", (join) => join
37
+ .onRef("sens.memgrppol.senmat", "=", "dosleg.votsen.senmat")
38
+ .onRef("sens.memgrppol.memgrppoldatdeb", "<=", scrutinDate)
39
+ .on((eb) => eb.or([
40
+ eb("sens.memgrppol.memgrppoldatfin", ">=", scrutinDate),
41
+ eb("sens.memgrppol.memgrppoldatfin", "is", null)
42
+ ])))
43
+ .where("dosleg.votsen.scrnum", "=", scrutinNum)
44
+ .where("dosleg.votsen.sesann", "=", scrutinSession)
45
+ .orderBy("sens.memgrppol.memgrppoldatdeb", "desc")
46
+ .select([
47
+ "dosleg.votsen.senmat",
48
+ "dosleg.posvot.posvotlib",
49
+ "dosleg.stavot.stavotlib",
50
+ "sens.memgrppol.grppolcod",
51
+ ])
52
+ .as("unique_votes"))
53
+ .groupBy([
54
+ "unique_votes.grppolcod",
55
+ ])
56
+ .select(({ fn, eb }) => [
57
+ "unique_votes.grppolcod as groupe_politique_code",
58
+ fn.sum(eb.case()
59
+ .when("unique_votes.posvotlib", "=", "pour")
60
+ .then(1)
61
+ .else(0)
62
+ .end()).as("nombre_pour"),
63
+ fn.sum(eb.case()
64
+ .when("unique_votes.posvotlib", "=", "contre")
65
+ .then(1)
66
+ .else(0)
67
+ .end()).as("nombre_contre"),
68
+ fn.sum(eb.case()
69
+ .when("unique_votes.posvotlib", "=", "abstention")
70
+ .then(1)
71
+ .else(0)
72
+ .end()).as("nombre_abstentions"),
73
+ fn.sum(eb.case()
74
+ .when("unique_votes.posvotlib", "=", "non-votant")
75
+ .then(1)
76
+ .else(0)
77
+ .end()).as("nombre_non_votants"),
78
+ fn.count("unique_votes.senmat").as("nombre_votants"),
79
+ ]));
80
+ }
29
81
  function misesAuPoint(scrutinNum) {
30
82
  return jsonArrayFrom(dbSenat
31
83
  .withSchema("dosleg")
@@ -65,6 +117,7 @@ const findAllScrutinsQuery = dbSenat
65
117
  "scr.scrpou as nombre_pour",
66
118
  "scr.scrpousea as nombre_pour_seance",
67
119
  votes(ref("scr.scrnum"), ref("scr.sesann"), ref("scr.scrdat")).as("votes"),
120
+ groupesVotants(ref("scr.scrnum"), ref("scr.sesann"), ref("scr.scrdat")).as("groupes_votants"),
68
121
  misesAuPoint(ref("scr.scrnum")).as("mises_au_point"),
69
122
  ])
70
123
  .$narrowType();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.15.6",
3
+ "version": "2.15.7",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",