blob: c644de8e942bf850fcd637a90c3faf1e95f6473c [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from google.appengine.ext import ndb
6
7
8class RedirectCustomValue(ndb.Model):
9 """Represents a project custome value redirect information."""
10 ProjectName = ndb.StringProperty()
11 MonorailType = ndb.StringProperty()
12 MonorailValue = ndb.StringProperty()
13 RedirectType = ndb.StringProperty()
14 RedirectValue = ndb.StringProperty()
15
16 @classmethod
17 def Get(cls, project, custom_type, value):
18 # TODO(b/283983843): add function to handle multiple values.
19 entity = cls.query(
20 RedirectCustomValue.ProjectName == project,
21 RedirectCustomValue.MonorailType == custom_type,
22 RedirectCustomValue.MonorailValue == value).get()
23 if not entity:
24 return None, None
25 return entity.RedirectType, entity.RedirectValue