Skip to content
Merged
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
20 changes: 15 additions & 5 deletions tools/cldr-apps/js/src/esm/cldrAccount.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,24 @@ function prettyLocaleList(locales) {
}

function getUserSeen(u) {
const when = u.data.active ? u.data.active : u.data.seen;
if (!when) {
return "";
}
const when = (u.data.active ? u.data.active : u.data.seen) || "never";
const what = u.data.active ? "active" : "seen";
let html = "<b>" + what + ": " + when + "</b>";
if (what === "seen") {
html += "<br /><font size='-2'>" + u.data.lastlogin + "</font></td>";
let created = u.data.firstdate;
if (!created) {
created = "unknown date; never voted?";
} else if (created < "2025-10-17") {
// Change 2023-05-04T20:00:00.000Z to 2023-05-04, for example.
created = "approximately " + created.replace(/T.+/, "");
}
const lastlogin = u.data.lastlogin || "never";
html +=
"<br /><font size='-2'>" +
lastlogin +
"<br />(account created " +
created +
")</font></td>";
}
return html;
}
Expand Down
5 changes: 3 additions & 2 deletions tools/cldr-apps/js/src/esm/cldrAddUser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ async function getOrgLocales(orgName) {
.doFetch(resource)
.then(cldrAjax.handleFetchErrors)
.then((r) => r.json())
.then(setOrgLocales)
.then((json) => setOrgLocales(orgName, json))
.catch((e) => addError(`Error: ${e} getting org locales`));
}

function setOrgLocales(json) {
function setOrgLocales(orgName, json) {
if (json.err) {
cldrRetry.handleDisconnect(json.err, json, "", "Loading org locales");
return;
Expand All @@ -87,6 +87,7 @@ function setOrgLocales(json) {
? Object.keys(cldrLoad.getTheLocaleMap().locmap.locales).join(" ")
: json.locales;
callbackToSetData({
orgName,
orgLocales,
});
}
Expand Down
7 changes: 4 additions & 3 deletions tools/cldr-apps/js/src/views/AddUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ function setData(data) {
if (data.orgObject) {
setOrgData(data.orgObject);
}
if (data.orgLocales) {
setOrgLocales(data.orgLocales);
if (data.orgName && data.orgLocales) {
setOrgLocales(data.orgName, data.orgLocales);
}
if (data.error) {
justGotError.value = true; // See comment in errorsExist()
Expand Down Expand Up @@ -303,7 +303,8 @@ function setOrgData(orgObject) {
newUserOrg.value = "";
}
function setOrgLocales(orgLocales) {
function setOrgLocales(orgName, orgLocales) {
newUserOrg.value = orgName;
if (!orgLocales) {
console.error("No locales for organization " + newUserOrg.value);
}
Expand Down
12 changes: 12 additions & 0 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/DBUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ public static boolean tableHasColumn(Connection conn, String table, String colum
> 0;
}

public static boolean addColumnIfMissing(
Connection conn, String tableName, String columnName, String type) throws SQLException {
if (DBUtils.tableHasColumn(conn, tableName, columnName)) {
return false; // Did not create since it already exists
}
Statement s = conn.createStatement();
String sql = "ALTER TABLE " + tableName + " ADD COLUMN " + columnName + " " + type;
s.execute(sql);
s.close();
return true;
}

private static byte[] encode_u8(String what) {
byte[] u8;
if (what == null) {
Expand Down
14 changes: 2 additions & 12 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -1511,18 +1511,8 @@ public synchronized void setupDB() {
s.close();
s = null; // don't close twice.
System.err.println("Created table " + DBUtils.Table.VOTE_VALUE);
} else if (!DBUtils.tableHasColumn(
conn, DBUtils.Table.VOTE_VALUE.toString(), VOTE_TYPE)) {
s = conn.createStatement();
sql =
"ALTER TABLE "
+ DBUtils.Table.VOTE_VALUE
+ " ADD COLUMN "
+ VOTE_TYPE
+ " TINYINT NOT NULL";
s.execute(sql);
s.close();
s = null;
} else if (DBUtils.addColumnIfMissing(
conn, DBUtils.Table.VOTE_VALUE.toString(), VOTE_TYPE, "TINYINT NOT NULL")) {
System.err.println(
"Added column " + VOTE_TYPE + " to table " + DBUtils.Table.VOTE_VALUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public static JSONObject wrap(UserRegistry.User u) throws JSONException {
.put("emailHash", u.getEmailHash())
.put("userlevelName", u.getLevel())
.put("org", u.org)
.put("time", u.last_connect);
.put("firstdate", u.firstdate)
.put("time", u.lastlogin);
}

public static JSONObject wrap(CheckCLDR check) throws JSONException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,7 @@ private void putShownUser(JSONArray shownUsers, UserSettings u) throws JSONExcep
(u.session == null)
? ""
: SurveyMain.timeDiff(u.session.getLastBrowserCallMillisSinceEpoch());
String seen =
(user.last_connect == null) ? "" : SurveyMain.timeDiff(user.last_connect.getTime());
String seen = (user.lastlogin == null) ? "" : SurveyMain.timeDiff(user.lastlogin.getTime());
boolean havePermToChange = me.isAdminFor(user);
boolean userCanDeleteUser = UserRegistry.userCanDeleteUser(me, user.id, user.userlevel);
VoteResolver.Level level = VoteResolver.Level.fromSTLevel(user.userlevel);
Expand All @@ -461,7 +460,8 @@ private void putShownUser(JSONArray shownUsers, UserSettings u) throws JSONExcep
.put("havePermToChange", havePermToChange)
.put("id", user.id)
.put("intlocs", user.intlocs)
.put("lastlogin", user.last_connect)
.put("firstdate", user.firstdate)
.put("lastlogin", user.lastlogin)
.put("locales", normalizeLocales(user.locales))
.put("badLocales", user.badLocales)
.put("name", user.name)
Expand Down
Loading
Loading