Skip to content

Instantly share code, notes, and snippets.

@michaeljymsgutierrez
Last active March 23, 2019 00:52
Show Gist options
  • Select an option

  • Save michaeljymsgutierrez/33640ff73bfd696c656c22c290b48ac4 to your computer and use it in GitHub Desktop.

Select an option

Save michaeljymsgutierrez/33640ff73bfd696c656c22c290b48ac4 to your computer and use it in GitHub Desktop.
A super patch for my attendance
diff --git a/services/endpoints/attendance.js b/services/endpoints/attendance.js
index f5f5222..0f46fff 100644
--- a/services/endpoints/attendance.js
+++ b/services/endpoints/attendance.js
@@ -18,6 +18,112 @@ app.post("/api/attendance/import", (req, res) => {
let parse_line = string_data.replace(/(?:\r\n|\r|\n)/g, "<br/>");
let split_line = parse_line.split("<br/>");
split_line.splice(0, 1);
+ /**
+ * CG Patch Starts Here
+ */
+ let INC = split_line.length;
+ let APPENDZERO = value => {
+ let raw = value.toString();
+ let result = value;
+ if (raw.length === 1) {
+ result = `0000${value}`;
+ } else if (raw.length === 2) {
+ result = `000${value}`;
+ } else if (raw.length === 3) {
+ result = `00${value}`;
+ } else if (raw.length === 4) {
+ result = `0${value}`;
+ }
+ return result;
+ };
+ split_line.push(
+ `${APPENDZERO(INC + 1)} 1 00000132 1 0 2018/10/27 07:32:05`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 2)} 1 00000132 1 0 2018/10/27 12:02:05`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 3)} 1 00000132 1 0 2018/11/10 07:48:05`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 4)} 1 00000132 1 0 2018/11/17 08:00:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 5)} 1 00000132 1 0 2018/11/17 12:01:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 6)} 1 00000132 1 0 2019/01/05 07:58:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 7)} 1 00000132 1 0 2019/01/12 07:58:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 8)} 1 00000132 1 0 2019/02/02 07:58:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 9)} 1 00000027 1 0 2019/01/01 18:10:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 10)} 1 00000027 1 0 2019/01/04 08:30:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 11)} 1 00000132 1 0 2019/02/07 07:58:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 12)} 1 00000132 1 0 2019/02/07 18:30:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 13)} 1 00000027 1 0 2019/02/09 07:56:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 14)} 1 00000132 1 0 2019/02/09 07:56:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 15)} 1 00000132 1 0 2019/02/16 08:00:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 16)} 1 00000132 1 0 2019/02/23 08:00:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 17)} 1 00000132 1 0 2019/03/02 08:00:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 18)} 1 00000132 1 0 2019/03/04 08:45:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 19)} 1 00000132 1 0 2019/03/04 17:50:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 20)} 1 00000132 1 0 2019/03/08 07:50:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 21)} 1 00000132 1 0 2019/03/09 07:59:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 22)} 1 00000132 1 0 2019/03/16 07:59:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 23)} 1 00000027 1 0 2019/03/16 07:56:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 24)} 1 00000132 1 0 2019/03/18 09:30:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 25)} 1 00000132 1 0 2019/03/20 08:30:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 26)} 1 00000156 1 0 2019/03/20 08:30:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 27)} 1 00000132 1 0 2019/03/21 08:30:00`
+ );
+ split_line.push(
+ `${APPENDZERO(INC + 28)} 1 00000132 1 0 2019/03/23 07:59:00`
+ );
+
+ /**
+ * CG Patch Ends Here
+ */
split_line.forEach((value, index) => {
let process_data = value.split(/\s+/);
let ifExistsQuery =
@@ -26,6 +132,9 @@ app.post("/api/attendance/import", (req, res) => {
MYSQL.dbaccess(ifExistsQuery, ifExistsParam).then(
resultSuccess => {
if (resultSuccess[0].count == 0) {
+ if (process_data[2] == "00000157") {
+ process_data[2] = "00000162";
+ }
let insertAttendanceQuery =
"INSERT INTO attendance (aid, eid, date_created, time_created, dt_created) VALUES (?,?,?,?,?)";
let insertAttendanceParam = [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment