-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheventSelector.py
140 lines (117 loc) · 6.27 KB
/
eventSelector.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
import random
# from event import Event
import endpoints
from protorpc import messages
from protorpc import message_types
from protorpc import remote
package = 'event'
'''
class EventSelector:
def __init__(self):
self.events = set()
def select_event(self, user):
valid_events = self.events - user.rejected_events
choice = random.sample(valid_events, 1)
user.rejected_events.add(choice)
return choice
def collect_events(self):
self.events = {Event("Walker"), Event("Mall of America")}
'''
# package = 'Hello' --- first thing in file
class Event(messages.Message):
"""Greeting that stores a message."""
name = messages.StringField(1)
url = messages.StringField(2)
cost = messages.StringField(3)
groupSize = messages.StringField(4)
duration = messages.StringField(5)
distance = messages.StringField(6)
description = messages.StringField(7)
class EventCollection(messages.Message):
"""Collection of Greetings."""
items = messages.MessageField(Event, 1, repeated=True)
STORED_EVENTS = EventCollection(items=[
Event(name = "Minnesota Wild v. Chicago Blackhawks",
url = "http://espn.go.com/video/clip?id=14808471&ex_cid=espnapi_public",
cost = "115",
groupSize = "2-4",
duration = "2.5-3 hours",
distance = "5 miles",
description = "Minnesota hosts Chicago in Minnesota's first-ever outdoor hockey game. The two central-division rivals square off at TCF Bank Stadium in Minneapolis, MN "),
Event(name = "Dropkick Murphys 20th Anniversary Tour",
url = "http://www.citypages.com/event/dropkick-murphys-20th-anniversary-tour-8048046",
cost = "Free! With ",
groupSize = "1",
duration = "",
distance = "3",
description = "Twenty years ago, a new brand of music hit the world when Dropkick Murphys took hard-edged street punk and mixed it with Irish tradition. Over the years, the band's lineup has changed and the waistbands of their kilts have expanded. But they still bring the fight, the fury, and the rock with the same anthemic rage that has made them popular with spike-wearing punks, sports fans, and Hibernophiles alike. On this trek across the U.S., Dropkick Murphys will be hitting clubs just in time for St. Paddy's Day pre-parties."),
Event(name = "Como Zoo Conservatory",
url = "http://www.comozooconservatory.org/plan/#/visitor-guide",
cost = "Free! With suggested $3 donation.",
groupSize = "Any size!",
duration = "1-5 hours",
distance = "6.2 miles",
description = "Enjoy exotic plants and beautiful displays in our various gardens. Learn more about a few of our animals before your visit."),
Event(name = "Google Developers Group - the Nerdery",
url = "http://www.meetup.com/gdg-tc/",
cost = "Free, but exp. recommended",
groupSize = "1+",
duration = "3 hours",
distance = "8.9 miles",
description = "Study Jams are community-organized study groups around Google online developer courses. The goal is to support as many students as possible in completing the course, thereby raising the technical level of the community."),
Event(name = "Go ice-skating outdoors! - Do Something!",
url = "",
cost = "Skate rental and modest rink fees! ",
groupSize = "As many as you want",
duration = "2.5-3 hours",
distance = "5 miles",
description = " "),
Event(name = "Minneapolis Institute of the Arts (MIA)",
url = "http://new.artsmia.org/",
cost = "Free",
groupSize = "Any",
duration = "2-4 hours",
distance = "5.9 miles",
description = "Come see the finest art from Minnesota and abroad. Our newest feature exhibit is 'State of the Art: Discovering American Art Now' (end May 29th)"),
Event(name = "Merlin's Rest Pub - Minneapolis, MN",
url = "http://espn.go.com/video/clip?id=14808471&ex_cid=espnapi_public",
cost = "$9-15 per person",
groupSize = "Call ahead for parties bigger than 6!",
duration = "Half-hour to 2 hours",
distance = "3 mi.",
description = "Whether your taste is for a hearty meal of Bangers and Mash or our authentic Fish and Chips (voted best Fish and Chips in the Twin Cities) you can wash it down with the finest beers of this land or any other - and the most comprehensive list of Irish and Scotch Whisky in all of Minnesota."),
Event(name = "Shopping at the Mall of America",
url = "https://www.mallofamerica.com/",
cost = "$0-$1,000,000,000",
groupSize = "1-45,000",
duration = "All Day!",
distance = "13 miles",
description = "As one of the most visited tourist destination in the world. MOA features 520 stores, 50 restaurants, and attractions galore, including Nickelodeon Universe - the nation's largest indoor theme park."),
Event(name = "Try ice fishing!",
url = "",
cost = "Free, with a DNR license",
groupSize = "2-6",
duration = "3-6 hours",
distance = "Any Lake",
description = "Get onto any of Minnesota more-than-10,000 lakes to drill holes in the ice and fish! Whether you're a beginner or a fishin' noobie, ice fishing in cold, winter MN is a pasttime worth your time.")])
@endpoints.api(name='events', version='v1')
class EventsApi(remote.Service):
"""Events API v1."""
@endpoints.method(message_types.VoidMessage, EventCollection,
path='events/list', http_method='GET',
name='eventsApi.listEvents')
def events_list(self, unused_request):
return STORED_EVENTS
ID_RESOURCE = endpoints.ResourceContainer(
message_types.VoidMessage,
id=messages.IntegerField(1, variant=messages.Variant.INT32))
@endpoints.method(ID_RESOURCE, Event,
path='events/{id}', http_method='GET',
name='eventsApi.getEvent')
def greeting_get(self, request):
try:
return random.choice(STORED_EVENTS.items)
except (IndexError, TypeError):
raise endpoints.NotFoundException('Event %s not found.' %
(request.id,))
APPLICATION = endpoints.api_server([EventsApi])