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
2 changes: 1 addition & 1 deletion deployment/stats/conf.json.template
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fr.wseduc~stats~1.12-SNAPSHOT",
"name": "fr.wseduc~stats~1.12.12",
"config": {
"main" : "fr.wseduc.stats.Stats",
"port" : 8225,
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ vertxVersion=3.9.5
toolsVersion=2.0.0-final
junitVersion=4.10

entCoreVersion=4.6-SNAPSHOT
entCoreVersion=4.9-SNAPSHOT
vertxCronTimer=2.0.0
jodaTimeVersion=2.9.4
27 changes: 4 additions & 23 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var gulp = require('gulp');
var webpack = require('webpack-stream');
var merge = require('merge2');
var rev = require('gulp-rev');
var revReplace = require("gulp-rev-replace");
const replace = require('gulp-replace');
var clean = require('gulp-clean');
var sourcemaps = require('gulp-sourcemaps');
var argv = require('yargs').argv;
var fs = require('fs');

Expand All @@ -13,16 +11,7 @@ gulp.task('drop-cache', function(){
.pipe(clean());
});

gulp.task('copy-files', ['drop-cache'], () => {
var html = gulp.src('./node_modules/entcore/src/template/**/*.html')
.pipe(gulp.dest('./src/main/resources/public/template/entcore'));
var bundle = gulp.src('./node_modules/entcore/bundle/*')
.pipe(gulp.dest('./src/main/resources/public/dist/entcore'));

return merge(html, bundle);
})

gulp.task('webpack', ['copy-files'], () => {
gulp.task('webpack', ['drop-cache'], () => {
return gulp.src('./src/main/resources/public')
.pipe(webpack(require('./webpack.config.js')))
.on('error', function handleError() {
Expand All @@ -31,17 +20,9 @@ gulp.task('webpack', ['copy-files'], () => {
.pipe(gulp.dest('./src/main/resources/public/dist'));
});

gulp.task('rev', ['webpack'], () => {
return gulp.src('./src/main/resources/public/dist/**/*.js')
.pipe(rev())
.pipe(gulp.dest('./src/main/resources/public/dist'))
.pipe(rev.manifest())
.pipe(gulp.dest('./'));
});

gulp.task('build', ['rev'], () => {
gulp.task('build', ['webpack'], () => {
var refs = gulp.src("./src/main/resources/view-src/**/*.+(html|json|csv)")
.pipe(revReplace({manifest: gulp.src("./rev-manifest.json") }))
.pipe(replace('@@VERSION', Date.now()))
.pipe(gulp.dest("./src/main/resources/view"));

var copyBehaviours = gulp.src('./src/main/resources/public/dist/behaviours.js')
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
"@types/core-js": "0.9.42",
"axios": "0.16.2",
"core-js": "2.4.1",
"entcore": "~4.6.0-dev",
"entcore": "~4.8.0-dev",
"entcore-toolkit": "^1.0.1",
"gulp": "3.9.1",
"gulp-clean": "^0.3.2",
"gulp-rev": "^7.1.2",
"gulp-rev-replace": "^0.4.3",
"gulp-sourcemaps": "^2.6.0",
"merge2": "^1.1.0",
"ts-loader": "^3.2.0",
"typescript": "3.9.5",
Expand All @@ -22,7 +19,8 @@
"yargs": "^8.0.2"
},
"devDependencies": {
"@types/jquery": "^2.0.34"
"@types/jquery": "^2.0.34",
"gulp-replace": "1.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
31 changes: 20 additions & 11 deletions src/main/java/fr/wseduc/stats/Stats.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@

import java.text.ParseException;

import io.vertx.pgclient.PgConnectOptions;
import io.vertx.pgclient.PgPool;
import io.vertx.pgclient.SslMode;
import io.vertx.sqlclient.PoolOptions;
import org.entcore.common.aggregation.MongoConstants.COLLECTIONS;
import org.entcore.common.events.EventHelper;
import org.entcore.common.events.EventStore;
import org.entcore.common.events.EventStoreFactory;
import org.entcore.common.http.BaseServer;
import org.entcore.common.mongodb.MongoDbConf;

import io.reactiverse.pgclient.PgClient;
import io.reactiverse.pgclient.PgPool;
import io.reactiverse.pgclient.PgPoolOptions;
import io.vertx.core.json.JsonObject;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
Expand Down Expand Up @@ -85,23 +86,31 @@ public void start() throws Exception {
final JsonObject readPGConfig = config.getJsonObject("read-pg-config");
final boolean oldStats = config.getBoolean("mongo-stats-service", false);
if (readPGConfig != null && !readPGConfig.isEmpty() && !oldStats) {
final PgPoolOptions options = new PgPoolOptions().setPort(readPGConfig.getInteger("port", 5432))
final PgConnectOptions connectOptions = new PgConnectOptions().setPort(readPGConfig.getInteger("port", 5432))
.setHost(readPGConfig.getString("host")).setDatabase(readPGConfig.getString("database"))
.setUser(readPGConfig.getString("user")).setPassword(readPGConfig.getString("password"))
.setMaxSize(readPGConfig.getInteger("pool-size", 5));
PgPool pgPool = PgClient.pool(vertx, options);
.setUser(readPGConfig.getString("user")).setPassword(readPGConfig.getString("password"));
final SslMode sslMode = SslMode.valueOf(readPGConfig.getString("ssl-mode", "DISABLE"));
if (!SslMode.DISABLE.equals(sslMode)) {
connectOptions.setSslMode(sslMode).setTrustAll(SslMode.ALLOW.equals(sslMode) || SslMode.PREFER.equals(sslMode) || SslMode.REQUIRE.equals(sslMode));
}
PoolOptions poolOptions = new PoolOptions().setMaxSize(readPGConfig.getInteger("pool-size", 5));
PgPool pgPool = PgPool.pool(vertx, connectOptions, poolOptions);
statsService = new PGStatsService(platformId, config.getJsonObject("api-allowed-values"));
((PGStatsService) statsService).setReadPgPool(pgPool);
} else if (eventStoreConfig != null && eventStoreConfig.getJsonObject("postgresql-slave") != null && !oldStats) {
final JsonObject eventStorePGConfig = eventStoreConfig.getJsonObject("postgresql-slave");
final PgPoolOptions options = new PgPoolOptions()
final PgConnectOptions connectOptions = new PgConnectOptions()
.setPort(eventStorePGConfig.getInteger("port", 5432))
.setHost(eventStorePGConfig.getString("host"))
.setDatabase(eventStorePGConfig.getString("database"))
.setUser(eventStorePGConfig.getString("user"))
.setPassword(eventStorePGConfig.getString("password"))
.setMaxSize(eventStorePGConfig.getInteger("pool-size", 5));
PgPool pgPool = PgClient.pool(vertx, options);
.setPassword(eventStorePGConfig.getString("password"));
final SslMode sslMode = SslMode.valueOf(eventStorePGConfig.getString("ssl-mode", "DISABLE"));
if (!SslMode.DISABLE.equals(sslMode)) {
connectOptions.setSslMode(sslMode).setTrustAll(SslMode.ALLOW.equals(sslMode) || SslMode.PREFER.equals(sslMode) || SslMode.REQUIRE.equals(sslMode));
}
PoolOptions poolOptions = new PoolOptions().setMaxSize(eventStorePGConfig.getInteger("pool-size", 5));
PgPool pgPool = PgPool.pool(vertx, connectOptions, poolOptions);
statsService = new PGStatsService(platformId, config.getJsonObject("api-allowed-values"));
((PGStatsService) statsService).setReadPgPool(pgPool);
} else {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/fr/wseduc/stats/services/PGStatsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import java.util.stream.IntStream;
import java.time.LocalDateTime;

import io.vertx.pgclient.PgPool;
import io.vertx.sqlclient.Row;
import io.vertx.sqlclient.RowSet;
import io.vertx.sqlclient.Tuple;
import org.entcore.common.utils.StringUtils;
import org.entcore.common.validation.ValidationException;

import fr.wseduc.webutils.Either;
import fr.wseduc.webutils.Utils;
import io.reactiverse.pgclient.PgPool;
import io.reactiverse.pgclient.PgRowSet;
import io.reactiverse.pgclient.Row;
import io.reactiverse.pgclient.Tuple;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
Expand Down Expand Up @@ -87,7 +87,7 @@ private void listStats(MultiMap params, boolean export, String language, Handler
}
log.info("query : " + query);
log.info("tuple : " + deepToString(t));
readPgPool.preparedQuery(query, t, pgRowsToEither(handler));
readPgPool.preparedQuery(query).execute(t, pgRowsToEither(handler));
} catch (Exception e) {
handler.handle(new Either.Left<>(e.getMessage()));
}
Expand Down Expand Up @@ -193,10 +193,10 @@ private String genDeviceQuery(MultiMap params, final List<String> entityIds, fin
return query;
}

private Handler<AsyncResult<PgRowSet>> pgRowsToEither(Handler<Either<String, JsonArray>> handler) {
private Handler<AsyncResult<RowSet<Row>>> pgRowsToEither(Handler<Either<String, JsonArray>> handler) {
return ar -> {
if (ar.succeeded()) {
final PgRowSet rows = ar.result();
final RowSet<Row> rows = ar.result();
final List<String> columns = rows.columnsNames();
final JsonArray res = new JsonArray();
for (Row row: rows) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/api-allowed-values.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"AideAuDevoirs","Alise","artips","Balado","BiblioCollege","Brne","Capytale","CerisePrim","CerisePro","Cesame","Chamilo",
"CIDJ","CNS","corelycee","DeltaExpert","Educagri","Educ-Arte","Edulib","Edulib2","Edulib-Belin","Edulib-Magnard","EduMalin","EduMaxicours","EduMedia",
"edumoov","Elea","Eliot","ElyceeHDF","English-Attack","Esidoc","EulerRessources","EulerRessources-pp","ExplorateurDeMetiers","FoliosOnisep",
"Formulaire","Formulaire-public","Diary","Edt","Competences","Viescolaire","Geogebra","GRR",
"HiSQOOL","Homework-assistance","HumanRoads","Interforum","InterForum","JuniorUniversalis","KiosqueEDU","KiosqueEDU-aca","KNE-Annabac","KNE-CNS","Kwyk","Labomep","LaboMEP",
"LDE","LeLivreScolaire","LeSite-tv","library","Lool","Lstl","madmagz","madmagz-77","madmagz-aisne","madmagz-draaf","madmagz-ent04","madmagz-idf","madmagz-na",
"Formulaire","Formulaire-public","Diary","Edt","Competences","Viescolaire","Geogebra","GRR", "Jupyter",
"HiSQOOL","HomeworkAssistance","HumanRoads","Interforum","InterForum","JuniorUniversalis","KiosqueEDU","KiosqueEDU-aca","KNE-Annabac","KNE-CNS","Kwyk","Labomep","LaboMEP",
"LDE","LeLivreScolaire","LeSite-tv","library","Lool","Lstl","Lystore","madmagz","madmagz-77","madmagz-aisne","madmagz-draaf","madmagz-ent04","madmagz-idf","madmagz-na",
"madmagz-nord","madmagz-oise","madmagz-paris","madmagz-regionhdf","madmagz-somme1d","madmagz-somme2d","milliweb-oAuth","MindViewOnline","Moodle","MSEL",
"numericours","numeritab","OGIL","OGIL-Region","Onisep","Onisep-Services","Passerelle","PasserellePise","Pearltrees","Peertube NA","PMB-lyceeconnecte","ProEPS",
"projet-voltaire","Pronote","Riot Region","Sacoche","Salvum","Scratch","Speakshake","Tactileo","TurboSelf","Universalis","Universalis-Junior",
"Webclasseur","Wekan Region","Wims-Auto","Wims-Euler","Wims-Math"
"numericours","numeritab","OGIL","OGIL-Region","Onisep","Onisep-Services","Passerelle","PasserellePise","Pearltrees","Peertube","PMB-lyceeconnecte","PMB-Gestion-lyceeconnecte",
"ProEPS","projet-voltaire","Pronote","Riot","Sacoche","Salvum","Scratch","Speakshake","Tactileo","TurboSelf","Universalis","Universalis-Junior",
"Webclasseur","Wekan","Wims-Auto","Wims-Euler","Wims-Math"
],
"devices-mapping" : {
"select-devices" : ["desktop", "mobile_app", "tablet"],
Expand Down
21 changes: 20 additions & 1 deletion src/main/resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,24 @@
"myaccount": "My Account",
"classparam": "Class settings",
"zimbra" : "Messaging",
"presences" : "Attendance"
"presences" : "Attendance",
"webconference": "Access to a virtual room",
"moodle": "Moodle",
"pmb-lyceeconnecte": "PMB",
"pmb-gestion-lyceeconnecte" : "PMB Gestion",
"capytale": "Capytale",
"cerisepro": "Cerise Pro",
"edumedia": "Edumedia",
"esidoc": "Esidoc",
"foliosonisep": "Folios Onisep",
"library": "Library",
"onisep": "Onisep",
"pronote": "Pronote",
"scratch": "Scratch",
"geogebra": "GeoGebra",
"lool": "Lool",
"riot": "Riot",
"wekan": "Wekan",
"peertube": "Peertube",
"jupyter": "Jupyter"
}
21 changes: 20 additions & 1 deletion src/main/resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,24 @@
"stats.error.nonadmlofstructure": "Vous n'avez pas accès aux statistiques de l'établissement, merci de sélectionner une classe",
"stats.error.nodata":"Données indisponibles",
"stats.support": "Support",
"webconference": "Accès à une salle virtuelle"
"webconference": "Accès à une salle virtuelle",
"homeworkassistance": "Homework-Assistance",
"moodle": "Moodle",
"pmb-lyceeconnecte": "PMB",
"pmb-gestion-lyceeconnecte" : "PMB Gestion",
"capytale": "Capytale",
"cerisepro": "Cerise Pro",
"edumedia": "Edumedia",
"esidoc": "Esidoc",
"foliosonisep": "Folios Onisep",
"library": "Bibliothèque",
"onisep": "Onisep",
"pronote": "Pronote",
"scratch": "Scratch",
"geogebra": "GeoGebra",
"lool": "Lool",
"riot": "Messagerie Riot",
"wekan": "Wekan",
"peertube": "Peertube",
"jupyter": "Jupyter"
}
7 changes: 3 additions & 4 deletions src/main/resources/view-src/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
<title>{{#i18n}}stats.title{{/i18n}}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/stats/public/dist/entcore/ng-app.js" type="text/javascript" id="context"></script>
<script src="/stats/public/dist/application.js" type="text/javascript"></script>
<!-- script src="/stats/public/js/chartjs/1.0.1-beta.3/Chart.min.js" type="text/javascript"></script -->
<!-- script src="/stats/public/js/chartjs/1.0.1-beta.3/Chart.StackedBar.js" type="text/javascript"></script -->

<script src="/assets/js/entcore/ng-app.js?v=@@VERSION" type="text/javascript" id="context"></script>
<script src="/stats/public/dist/application.js?v=@@VERSION" type="text/javascript"></script>

<script src="/stats/public/js/chartjs/2.9.3/Chart.bundle.min.js" type="text/javascript"></script>
<script type="text/ng-template" id="empty"></script>
</head>
Expand Down