diff options
-rwxr-xr-x | test_date.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test_date.sh b/test_date.sh new file mode 100755 index 0000000..546aacf --- /dev/null +++ b/test_date.sh @@ -0,0 +1,53 @@ +#!/bin/bash +if [ $# -ne 1 ] +then + echo "usage: $0 name@domain.sth" + exit -1; +fi +echo "populating db for user $1" + +dbName='testDB.db' +sqlite="sqlite3" +JIDs=('andrew@gmail.com' 'john@gmail.com' 'carol@redcode.com' 'nick@foss.org' 'james@random.org') +selfJID=$1 +randomWords=('cheese' 'house' 'berry' 'tree' 'glass' 'door' 'music' 'work') + +baseStatement="INSERT INTO messages('message', 'fromBare', 'fromResource', 'toBare', 'toResource', 'type', 'time') VALUES(" +baseMessage="Message from: " + +firstDay=1 +lastDay=8 +month=6 + +$sqlite -line $dbName "CREATE TABLE IF NOT EXISTS messages('message' STRING, 'fromBare' INTEGER, 'fromResource' STRING, 'toBare' INTEGER, 'toResource' STRING, 'type' INTEGER, 'time' INTEGER, 'offset' INTEGER);" + +$sqlite -line $dbName "CREATE TABLE IF NOT EXISTS jids('id' INTEGER PRIMARY KEY ASC AUTOINCREMENT, 'jid' STRING UNIQUE NOT NULL);" + +$sqlite -line $dbName "INSERT INTO jids('jid') VALUES('$selfJID');" + +for (( id=2; id<${#JIDs[@]} + 2; id++ )) +do + echo $id + $sqlite -line $dbName "INSERT INTO jids('jid') VALUES('${JIDs[$((id - 2))]}');" + for (( i=$firstDay; i<lastDay; i++ )) + do + for (( r=0; r < $((RANDOM%29)); r++ )) + do + for (( c=0; c < $((RANDOM%12)); c++ )) + do + date=$(date --date="$month/$i/12" +%s) + message="$baseMessage$month/$i/12:$c ${randomWords[$((RANDOM%100))]}" + statement="$baseStatement '$message', $id, '', 1, '', 0, $((date + c * 30 + 3600 * 8)));" + $sqlite -line $dbName "$statement" + done + + for (( c=0; c < $((RANDOM%12)); c++ )) + do + date=$(date --date="$month/$i/12" +%s) + message="$baseMessage$month/$i/12:$c ${randomWords[$((RANDOM%100))]}" + statement="$baseStatement '$message', 1, '', $id, '', 0, $((date + c * 60 + 3600 * 8)));" + $sqlite -line $dbName "$statement" + done + done + done +done |