summaryrefslogtreecommitdiffstats
blob: 546aacf8ba1ddae9403ad8963f5b8019c2710eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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