Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | # 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 | |
| 5 | from google.appengine.ext import ndb |
| 6 | |
| 7 | |
| 8 | class 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 |