Debian Codegraph @

gavo/resources/inputs/__system__/tap_user.rd

raw
1 <resource schema="tap_user" resdir="__system"
2 allProfiles="feed,trustedquery,untrustedquery">
3 <meta name="creationDate">2024-09-17T12:00:00</meta>
4 <meta name="description">A schema containing users' uploads. Tables
5 uploaded here are persistent across TAP requests but will automatically
6 be garbage collected after \getConfig{ivoa}{userTableDays} days.
7 Users are most welcome to delete them manually before that time by
8 doing a DELETE request against the table URI.</meta>
9 <meta name="subject">virtual-observatories</meta>
10 <meta name="subject">catalogs</meta>
11 <meta name="schema-rank">10</meta>
12
13 <!-- this is only loaded when user tables are actually accessed; hence,
14 the following job should only run when there's actually user tables.
15 Still, don't assume anything is functional here, as operators will
16 receive mails if things go wrong in an exec. -->
17
18 <execute every="-80000" title="Clean user-uploaded tables" id="expire">
19 <job>
20 <setup imports="gavo.web.tap_uploads"/>
21 <code>
22 with base.getWritableAdminConn() as conn:
23 toDelete = conn.query("select user_name, table_name"
24 " from tap_user.tables"
25 " where expiry&lt;=CURRENT_TIMESTAMP")
26 for userName, tableName in toDelete:
27 tap_uploads.dropUserUploadedTable(
28 conn, userName, tableName)
29 </code>
30 </job>
31 </execute>
32
33 <table id="tables" onDisk="True" system="True"
34 primary="user_name,table_name"
35 allProfiles="feed,trustedquery,untrustedquery"
36 dupePolicy="overwrite">
37 <meta name="description">This table contains metadata for the tables
38 uploaded by users.
39 </meta>
40
41 <column name="user_name" type="text"
42 description="Identifier for the uploading user; NULL is for
43 anonymous uploads."/>
44 <column name="table_name" type="text"
45 description="User-configured table name"/>
46 <column name="physical_name" type="text"
47 description="Name of the table within the tap_user_tables schema."/>
48 <column name="metadata" type="text"
49 description="DaCHS tableDef for this table"/>
50 <column name="expiry" type="timestamp"
51 description="Date and time this table will be garbage collected."/>
52 </table>
53
54 <data id="create">
55 <make table="tables"/>
56 </data>
57
58 <service id="create-index" allowed="async">
59 <pythonCore>
60 <inputTable>
61 <inputKey name="table_name"
62 description="Name of the table to operate on"
63 multiplicity="single"
64 required="True"/>
65 <inputKey name="index_name"
66 description="Name of the index within the table"
67 multiplicity="single"
68 required="True"/>
69 </inputTable>
70
71 <coreProc>
72 <setup imports="gavo.web.tap_uploads"/>
73 <code>
74 if queryMeta["user_pretend"]:
75 user = queryMeta.getAuthUser()
76 else:
77 user = "anonymous"
78
79 tap_uploads.createIndex(
80 user, inputTable.args["table_name"], inputTable.args["index_name"])
81 </code>
82 </coreProc>
83 </pythonCore>
84 </service>
85 </resource>