[2058] in Moira
staff load: distinguish first name with spaces from first and middle
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Mon Feb 23 20:26:46 2004
Message-Id: <200402240126.i1O1QgWJ029688@w20-spare-220r.mit.edu>
To: moiradev@MIT.EDU
Date: Mon, 23 Feb 2004 20:26:42 -0500
From: Garry Zacheiss <zacheiss@MIT.EDU>
It was pointed out to me today that there is currently a user in the
warehouse with a first name of "Mary Ellen" and no middle name. The
staff load program uses the full_name column of the
wareuser.moira_employee view in the warehouse, which makes it impossible
to distinguish this case from first name of "Mary" and middle name of
"Ellen". This actually turns out to matter in some cases.
Fortunately, it's easy to fix, by slightly changing the format of the
file staff.sql generates and using the first_name, middle_name, and
last_name columns instead of the full_name column. Tested patch below.
The one thing this changes is that we no longer get things like "Jr" and
"III" at the end of names. I don't think this matters; Laura is of the
opinion it's actually a good thing. This patch doesn't remove all of
the machinery for dealing with them; that will come at some later date.
Garry
Index: staff.pc
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/regtape/staff.pc,v
retrieving revision 1.6
diff -u -r1.6 staff.pc
--- staff.pc 16 Mar 2001 20:18:18 -0000 1.6
+++ staff.pc 23 Feb 2004 22:53:21 -0000
@@ -24,7 +24,9 @@
/* File format is:
*
* id number [9]
- * name (last, first middle) [30]
+ * last name [30]
+ * first name [30]
+ * middle name [30]
* office address [24]
* phone1 [12]
* phone2 [12]
@@ -34,9 +36,13 @@
#define LOC_ID 0
#define LEN_ID 9
-#define LOC_NAME (LOC_ID + LEN_ID)
-#define LEN_NAME 30
-#define LOC_OFFICE (LOC_NAME + LEN_NAME)
+#define LOC_LAST_NAME (LOC_ID + LEN_ID)
+#define LEN_LAST_NAME 30
+#define LOC_FIRST_NAME (LOC_LAST_NAME + LEN_LAST_NAME)
+#define LEN_FIRST_NAME 30
+#define LOC_MIDDLE_NAME (LOC_FIRST_NAME + LEN_FIRST_NAME)
+#define LEN_MIDDLE_NAME 30
+#define LOC_OFFICE (LOC_MIDDLE_NAME + LEN_MIDDLE_NAME)
#define LEN_OFFICE 24
#define LOC_PHONE (LOC_OFFICE + LEN_OFFICE)
#define LEN_PHONE 12
@@ -137,7 +143,8 @@
{
static struct entry e;
static char buf[BUFSIZ];
- static char name[LEN_NAME + 1], id[LEN_ID + 1];
+ static char last_name[LEN_LAST_NAME + 1], id[LEN_ID + 1];
+ static char first_name[LEN_FIRST_NAME + 1], middle_name[LEN_MIDDLE_NAME + 1];
static char office[LEN_OFFICE + 1], phone[LEN_PHONE + 1];
static char phone2[LEN_PHONE2 + 1], dept[LEN_DEPT + 1], title[LEN_TITLE + 1];
int ends_sr, ends_jr, ends_iii, ends_iv, ends_ii, ends_v;
@@ -147,41 +154,19 @@
return NULL;
strlcpy(id, &buf[LOC_ID], LEN_ID + 1);
- strlcpy(name, &buf[LOC_NAME], LEN_NAME + 1);
+ strlcpy(last_name, &buf[LOC_LAST_NAME], LEN_LAST_NAME + 1);
+ strlcpy(first_name, &buf[LOC_FIRST_NAME], LEN_FIRST_NAME + 1);
+ strlcpy(middle_name, &buf[LOC_MIDDLE_NAME], LEN_MIDDLE_NAME + 1);
strlcpy(office, &buf[LOC_OFFICE], LEN_OFFICE + 1);
strlcpy(phone, &buf[LOC_PHONE], LEN_PHONE + 1);
strlcpy(phone2, &buf[LOC_PHONE2], LEN_PHONE2 + 1);
strlcpy(dept, &buf[LOC_DEPT], LEN_DEPT + 1);
strlcpy(title, &buf[LOC_TITLE], LEN_TITLE + 1);
- p = strchr(name, ',');
- if (p)
- *p = '\0';
- e.last = strtrim(name);
- if (p)
- {
- p++;
- while (isspace(*p))
- p++;
- e.first = p;
- p = strchr(e.first, ' ');
- if (p)
- {
- *p = '\0';
- e.first = strtrim(e.first);
- e.middle = strtrim(p + 1);
- }
- else
- {
- e.first = strtrim(e.first);
- e.middle = "";
- }
- }
- else
- {
- e.first = "";
- e.middle = "";
- }
+ e.last = strtrim(last_name);
+ e.first = strtrim(first_name);
+ e.middle = strtrim(middle_name);
+
ends_sr = ends_jr = ends_iii = ends_iv = ends_ii = ends_v = 0;
LookForSt(e.last);
LookForO(e.last);
Index: staff.sql
===================================================================
RCS file: /afs/athena.mit.edu/astaff/project/moiradev/repository/moira/regtape/staff.sql,v
retrieving revision 1.2
diff -u -r1.2 staff.sql
--- staff.sql 16 Sep 2002 22:32:10 -0000 1.2
+++ staff.sql 23 Feb 2004 22:36:28 -0000
@@ -1,8 +1,8 @@
set head off
set feedback off
set pagesize 0
-set linesize 271
+set linesize 331
spool /moira/load/staff.input.unsorted
-select mit_id || rpad(nvl(full_name, ' '), 30, ' ') || rpad(substr(nvl(office_location, ' '), 0, 12), 12, ' ') || rpad(substr(nvl(secondary_office_location, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(office_phone, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(secondary_office_phone, ' '), 0, 12), 12, ' ') || rpad(substr(department_name, 0, 50), 50, ' ') || substr(directory_title, 0, 50) from wareuser.moira_employee;
+select mit_id || rpad(nvl(last_name, ' '), 30, ' ') || rpad(nvl(first_name, ' '), 30, ' ') || rpad(nvl(middle_name, ' '), 30, ' ') || rpad(substr(nvl(office_location, ' '), 0, 12), 12, ' ') || rpad(substr(nvl(secondary_office_location, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(office_phone, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(secondary_office_phone, ' '), 0, 12), 12, ' ') || rpad(substr(department_name, 0, 50), 50, ' ') || substr(directory_title, 0, 50) from wareuser.moira_employee;
spool off
quit