generated from Synteraction-Lab/TemplateRepository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
notification_data.py
476 lines (437 loc) · 11.4 KB
/
notification_data.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# coding=utf-8
import utilities
from random import shuffle
index_training_data = -1
index_testing_data = -1
order_testing_data = []
NOTIFICATION_TYPE_NONE = 'none'
NOTIFICATION_TYPE_TEXT_LONG = 'text_long'
NOTIFICATION_TYPE_IMAGE_SHORT = 'image_short'
NOTIFICATION_TYPE_TEXT_SHORT = 'text_short'
NOTIFICATION_TYPE_IMAGE_LONG = 'image_long'
def is_no_notification(type):
return type == NOTIFICATION_TYPE_NONE
def get_all_testing_notifications():
return NOTIFICATION_TESTING_DATA.copy()
def shuffle_data():
print("shuffle_data")
shuffle(NOTIFICATION_TRAINING_IMAGE_DATA)
shuffle(NOTIFICATION_TRAINING_TEXT_SHORT_DATA)
def get_next_notification_training_data(data_type):
global index_training_data
if data_type == NOTIFICATION_TYPE_IMAGE_SHORT:
data_list = NOTIFICATION_TRAINING_IMAGE_DATA
elif data_type == NOTIFICATION_TYPE_TEXT_SHORT:
data_list = NOTIFICATION_TRAINING_TEXT_SHORT_DATA
else:
return NOTIFICATION_EMPTY
index_training_data += 1
if index_training_data >= len(data_list):
index_training_data = 0
return data_list[index_training_data].copy()
SEQUENCE_FILE_NOTIFICATION = "_sequence_testing_notifications.json"
def is_supported_type(data_type):
if data_type == NOTIFICATION_TYPE_TEXT_LONG or \
data_type == NOTIFICATION_TYPE_IMAGE_SHORT or \
data_type == NOTIFICATION_TYPE_TEXT_SHORT or \
data_type == NOTIFICATION_TYPE_IMAGE_LONG:
return True
return False
# data_type = DATA_TYPE_TEXT -> text, DATA_TYPE_IMAGE -> image
def get_next_notification_testing_data(data_type):
global index_testing_data
global order_testing_data
if not is_supported_type(data_type):
return NOTIFICATION_EMPTY
data_list = NOTIFICATION_TESTING_DATA
# at start check whether there is saved data
if index_testing_data == -1:
order_testing_data, index_testing_data = utilities.read_order_data(
SEQUENCE_FILE_NOTIFICATION)
if order_testing_data is None:
print('\n Creating a new notification order\n')
order_testing_data = list(range(len(data_list)))
shuffle(order_testing_data)
index_testing_data = -1
else:
print('\n Loading the previous notification order\n')
index_testing_data += 1
if index_testing_data >= len(data_list):
index_testing_data = 0
# FIXME: this logic is wrong
while data_list[order_testing_data[index_testing_data]].get(data_type) is None:
index_testing_data += 1
if index_testing_data >= len(data_list):
index_testing_data = 0
# save the current data
utilities.save_order_data(SEQUENCE_FILE_NOTIFICATION, order_testing_data, index_testing_data)
return data_list[order_testing_data[index_testing_data]][data_type].copy()
NOTIFICATION_EMPTY = {
"id": 0,
"subheading": ""
}
NOTIFICATION_TRAINING_IMAGE_DATA = [
{
"id": 21,
"subheading": " Mary",
"image": "#FF00FF7D img_call"
},
{
"id": 22,
"subheading": " 8 am",
"image": "#FF00FF7D img_alarm"
},
{
"id": 23,
"subheading": " 10%",
"image": "#FF00FF7D img_battery_low"
}
]
NOTIFICATION_TRAINING_TEXT_SHORT_DATA = [
{
"id": 1,
"subheading": "Swimming 5 pm"
},
{
"id": 2,
"subheading": "Visit museum"
},
{
"id": 3,
"subheading": "Deposit SGD 10"
}
]
# count = 19
NOTIFICATION_TESTING_DATA = [
{
'text_short': {
"id": 301,
"subheading": "Meeting 4 pm"
},
# 'image_short': {
# "id": 301,
# "subheading": " 4 pm",
# "image": "#FF00FF7D img_meeting"
# },
},
{
'text_short': {
"id": 303,
"subheading": "Lunch Lee"
},
# 'image_short': {
# "id": 303,
# "subheading": " Lee",
# "image": "#FF00FF7D img_lunch"
# },
},
{
'text_short': {
"id": 309,
"subheading": "Pay SGD 200"
},
# 'image_short': {
# "id": 309,
# "subheading": " SGD 200",
# "image": "#FF00FF7D img_pay_cash"
# },
},
{
'text_short': {
"id": 312,
"subheading": "Presentation 12 pm"
},
# 'image_short': {
# "id": 312,
# "subheading": " 12 pm",
# "image": "#FF00FF7D img_presentation"
# },
},
{
'text_short': {
"id": 317,
"subheading": "Reply Alex"
},
# 'image_short': {
# "id": 317,
# "subheading": " Alex",
# "image": "#FF00FF7D img_reply"
# },
},
{
'text_short': {
"id": 321,
"subheading": "Movie Sunday"
},
# 'image_short': {
# "id": 321,
# "subheading": " Sunday",
# "image": "#FF00FF7D img_movie"
# },
},
{
'image_short': {
"id": 307,
"subheading": " 5 min",
"image": "#FF00FF7D img_car"
},
# 'text_short': {
# "id": 307,
# "subheading": "Car 5 min"
# },
},
{
'image_short': {
"id": 304,
"subheading": " John",
"image": "#FF00FF7D img_birthday"
},
# 'text_short': {
# "id": 304,
# "subheading": "Birthday John"
# },
},
{
'image_short': {
"id": 308,
"subheading": " 3 d",
"image": "#FF00FF7D img_delivery"
},
# 'text_short': {
# "id": 308,
# "subheading": "Delivery 3 d"
# },
},
{
'image_short': {
"id": 315,
"subheading": " 40 min",
"image": "#FF00FF7D img_exercise"
},
# 'text_short': {
# "id": 315,
# "subheading": "Exercise 40 min"
# },
},
{
'image_short': {
"id": 316,
"subheading": " status",
"image": "#FF00FF7D img_flight"
},
# 'text_short': {
# "id": 316,
# "subheading": "Flight status"
# },
},
{
'image_short': {
"id": 310,
"subheading": " today",
"image": "#FF00FF7D img_credit_card"
},
# 'text_short': {
# "id": 310,
# "subheading": "Credit card today"
# },
},
{
'text_long': {
"id": 330,
"subheading": "Valentine's day 2 d"
},
# 'image_long': {
# "id": 330,
# "subheading": " 2 d",
# "image": "#FF00FF7D img_valentine_day"
# },
},
{
'text_long': {
"id": 331,
"subheading": "Sync photos Friday"
},
# 'image_long': {
# "id": 331,
# "subheading": " Friday",
# "image": "#FF00FF7D img_sync_photos"
# },
},
{
'text_long': {
"id": 332,
"subheading": "Bus departure 25 min"
},
# 'image_long': {
# "id": 332,
# "subheading": " 25 min",
# "image": "#FF00FF7D img_bus"
# },
},
{
'text_long': {
"id": 333,
"subheading": "Order online Amazon"
},
# 'image_long': {
# "id": 333,
# "subheading": " Amazon",
# "image": "#FF00FF7D img_order_online"
# },
},
{
'text_long': {
"id": 334,
"subheading": "Apply leave vacation"
},
# 'image_long': {
# "id": 334,
# "subheading": " vacation",
# "image": "#FF00FF7D img_leave"
# },
},
{
'text_long': {
"id": 313,
"subheading": "Pay rental Monday"
},
# 'image_long': {
# "id": 313,
# "subheading": " Monday",
# "image": "#FF00FF7D img_pay_rent"
# },
},
{
'image_long': {
"id": 301,
"subheading": " 2 hrs",
"image": "#FF00FF7D img_doctor"
},
# 'text_long': {
# "id": 301,
# "subheading": "Doctor's appointment 2 hrs"
# },
},
{
'image_long': {
"id": 320,
"subheading": " tonight",
"image": "#FF00FF7D img_backup_computer"
},
# 'text_long': {
# "id": 320,
# "subheading": "Backup computer tonight"
# },
},
{
'image_long': {
"id": 318,
"subheading": " renew",
"image": "#FF00FF7D img_licence"
},
# 'text_long': {
# "id": 318,
# "subheading": "Driving license renew"
# },
},
{
'image_long': {
"id": 314,
"subheading": " FairPrice",
"image": "#FF00FF7D img_milk_eggs"
},
# 'text_long': {
# "id": 314,
# "subheading": "Milk and eggs FairPrice"
# },
},
{
'image_long': {
"id": 335,
"subheading": " EzLink",
"image": "#FF00FF7D img_topup_cash"
},
# 'text_long': {
# "id": 335,
# "subheading": "Top-up cash EzLink"
# },
},
{
'image_long': {
"id": 305,
"subheading": " 7 d",
"image": "#FF00FF7D img_mom_day"
},
# 'text_long': {
# "id": 305,
# "subheading": "Mother's day 7 d"
# },
},
# {
# 'text_short': {
# "id": 324,
# "subheading": "Download e-bill"
# },
# 'image_short': {
# "id": 324,
# "subheading": " e-bill",
# "image": "#FF00FF7D img_download"
# },
# },
# {
# 'text_short': {
# "id": 325,
# "subheading": "Coffee Sam"
# },
# 'image_short': {
# "id": 324,
# "subheading": " Sam",
# "image": "#FF00FF7D img_coffee"
# },
# },
# {
# 'text_short': {
# "id": 326,
# "subheading": "Email agenda"
# },
# 'image_short': {
# "id": 326,
# "subheading": " agenda",
# "image": "#FF00FF7D img_email"
# },
# },
#
# {
# 'text_long': {
# "id": 327,
# "subheading": "Take photo Zoo"
# },
# 'image_long': {
# "id": 327,
# "subheading": " Zoo",
# "image": "#FF00FF7D img_take_photo"
# },
# },
# {
# 'text_long': {
# "id": 328,
# "subheading": "Visitor coming 1 month"
# },
# 'image_long': {
# "id": 328,
# "subheading": " 1 month",
# "image": "#FF00FF7D img_visitor"
# },
# },
# {
# 'text_long': {
# "id": 329,
# "subheading": "Stand up stretch"
# },
# 'image_long': {
# "id": 329,
# "subheading": " stretch",
# "image": "#FF00FF7D img_standup"
# },
# },
]