Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fetchEventByShortname(dsn, eventname) {
try {
var conn=ibmdb.openSync(dsn);
// Search for exact match only, could be extended with lIKE
var data=conn.querySync("select shortname, location, begindate, enddate, contact from events where shortname=? fetch first 10 rows only", eventname);
conn.closeSync();
var resString="Date:\n";
for (var i=0;i
function fetchEventByDates(dsn, eventdates) {
try {
var conn=ibmdb.openSync(dsn);
// Base data is timestamp
var data=conn.querySync("select shortname, location, begindate, enddate, contact from events where begindate between ? and ?", eventdates);
conn.closeSync();
var resString="Data: \n";
for (var i=0;i
sum(clonecount) as clonecount, sum(cuniques) as cuniques
from v_repostats r, v_adminuserrepos v
where r.rid=v.rid
and tdate between this_week(current date - 7 days)+1 and (this_week(current date))
and v.email=?
group by r.rid, orgname, reponame
order by vuniques desc
fetch first 25 rows only`;
const repoCountSql=`select count(rid) as repocount
from v_adminuserrepos
where email=?`;
try {
// connect to database
var conn=ibmdb.openSync(dsn);
// retrieve weekly stats
var data=conn.querySync(weeklySql,[emailid]);
// retrieve repository count
var repoCount=conn.querySync(repoCountSql,[emailid]);
// close the connection
conn.closeSync();
// Compose the strings for the message and attachment
//
// We need the work week string for the previous week
var workweek=moment().subtract(7, 'days').format("YYYY-WW");
// the repository count
var resString="*Total repositories*: "+repoCount[0]['REPOCOUNT'];
resString+="\nSee more at INSERT YOUR URI here";
function insertEvent(dsn, eventValues) {
try {
var conn=ibmdb.openSync(dsn);
// The timestamp value is derived from date and time values passed in
var data=conn.querySync("insert into events(shortname, location, begindate, enddate, contact) values(?,?,timestamp_format(?||' '||?,'YYYY-MM-DD HH24:MI:SS'),timestamp_format(?||' '||?,'YYYY-MM-DD HH24:MI:SS'),?)", eventValues);
conn.closeSync();
return {result : data};
} catch (e) {
return { dberror : e }
}
}
function db2Setup(dsn, mode) {
try {
var tabledef="create table events "+
"(eid int not null generated always as identity (start with 1000, increment by 1),"+
"shortname varchar(20) not null,"+
"location varchar(60) not null,"+
"begindate timestamp not null,"+
"enddate timestamp not null,"+
"contact varchar(255) not null);";
var sampledata="insert into events(shortname,location,begindate,enddate,contact) values('Think 2019','San Francisco','2019-02-12 00:00:00','2019-02-15 23:59:00','https://www.ibm.com/events/think/'),('IDUG2019','Charlotte','2019-06-02 00:00:00','2019-06-06 23:59:00','http://www.idug.org');"
var tabledrop="drop table events;"
var conn=ibmdb.openSync(dsn);
if (mode=="setup")
{
var data=conn.querySync(tabledef);
} else if (mode=="sampledata")
{
var data=conn.querySync(sampledata);
} else if (mode=="cleanup")
{
var data=conn.querySync(tabledrop);
}
conn.closeSync();
return {result : data};
} catch (e) {
return { dberror : e }
}
}